Package:
@hexos/runtimeStreams LLM responses and tool executions using the Anthropic Messages API.
This generator function orchestrates the complete agent-tool interaction loop:
- Builds system prompt (static or dynamic) from agent definition
- Streams LLM response chunks, yielding text-delta events
- Detects tool calls and yields tool-call-start events
- Parses tool arguments and yields tool-call-args events
- Optionally waits for approval via approval-required/waitForApproval
- Executes tools via dependencies.executeToolWithGuards
- Yields tool-call-result or tool-call-error events
- Continues conversation with tool results until completion or max iterations
Supports extended thinking (reasoning-delta events) and lifecycle hooks (onToolCall, onToolResult). All infrastructure errors are retried via dependencies.withInfrastructureRetry.
function streamWithAnthropicProvider(params: AnthropicStreamParams): AsyncGenerator<RuntimeEvent>Parameters