Skip to main content

Module run

Module run 

Source
Expand description

The agent loop: stream a response, run its tool calls, repeat.

Port of packages/agent/src/agent-loop.ts in pi v1.0.0.

Structs§

AgentContext
The transcript and the tools the model may call.
LoopConfig
How the loop calls the model.
ToolCallOutcome
What a tool call produced.
ToolCallScope
Where a tool call runs: the tools it resolves against, the response and transcript its hooks see, and its cancellation.

Functions§

run
Runs the loop for new prompt messages and returns every message it added.
run_continue
Continues from the current transcript, which must not end with an assistant message.
run_tool_call
Runs one call outside the loop’s batches, as pi’s runToolCall does: it prepares and validates the call, passes it through the hooks and executes it in scope. Failures come back as error results. Emits no events: updates receives the tool’s partial results.

Type Aliases§

StreamFn
Starts a provider request through the model’s wire API. An error before any request ends the run, as pi’s agent ends it when its stream function throws.