DocsReact CorehooksUseAgentReturn
Package: @hexos/react-core

Return type of the useAgent hook, providing full agent interaction controls and state.

Exposes the message history (including the live streaming message), send/edit/regenerate functions, streaming state, active agent info, handoff history, and pending tool approvals.

interface UseAgentReturn {
    messages: AgentMessage[];
    sendMessage: (content: string, attachments?: Attachment[]) => Promise<void>;
    isStreaming: boolean;
    activeAgent: string | null;
    error: Error | null;
    clearError: () => void;
    reset: () => void;
    stop: () => void;
    regenerate: () => Promise<void>;
    editMessage: (messageId: string, newContent: string) => Promise<void>;
    conversationId: string | null;
    handoffHistory: HandoffEvent[];
    lastHandoff: HandoffEvent | null;
    pendingApprovals: ToolApprovalRequest[];
}

messages

sendMessage

(content: string, attachments?: Attachment[]) => Promise

isStreaming

boolean

activeAgent

string | null

error

Error | null

clearError

() => void

reset

() => void

stop

() => void

regenerate

() => Promise

editMessage

(messageId: string, newContent: string) => Promise

conversationId

string | null

handoffHistory

lastHandoff

pendingApprovals