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§
- Agent
Context - The transcript and the tools the model may call.
- Loop
Config - How the loop calls the model.
- Tool
Call Outcome - What a tool call produced.
- Tool
Call Scope - 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
runToolCalldoes: it prepares and validates the call, passes it through the hooks and executes it inscope. Failures come back as error results. Emits no events:updatesreceives the tool’s partial results.
Type Aliases§
- Stream
Fn - 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.