Skip to content

AIDK API Reference / aidk-react / useExecution

Function: useExecution() ​

ts
function useExecution(options: UseExecutionOptions): UseExecutionReturn;

Defined in: packages/react/src/hooks/useExecution.ts:83

Hook for managing agent execution with message accumulation

Parameters ​

ParameterType
optionsUseExecutionOptions

Returns ​

UseExecutionReturn

Example ​

tsx
function Chat() {
  const { client } = useEngineClient({ ... });

  const {
    sendMessage,
    isStreaming,
    messages,
    error
  } = useExecution({
    client,
    agentId: 'task-assistant',
  });

  return (
    <div>
      {messages.map(msg => <MessageBubble key={msg.id} message={msg} />)}
      {isStreaming && <LoadingIndicator />}
      <input onSubmit={(text) => sendMessage(text)} disabled={isStreaming} />
    </div>
  );
}

Released under the MIT License.