Skip to content

@sqlrooms/ai / processAgentStream

Function: processAgentStream()

processAgentStream(agentResult, store, parentToolCallId): Promise<string>

Processes an agent stream result, tracking tool calls and forwarding chunks to the writer

This function handles:

  • Tracking all tool calls made by the agent
  • Updating session additional data for UI progress rendering
  • Forwarding text deltas and tool outputs to the stream writer
  • Returning the final text result

Parameters

ParameterTypeDescription
agentResultAgentStreamResultThe stream result from agent.stream()
storeStoreApi<AiSliceState>The store containing AiSliceState
parentToolCallIdstringThe tool call ID of the parent agent tool (for storing additional data)

Returns

Promise<string>

The final text output from the agent