Skip to main content

Module agent

Module agent 

Source
Expand description

The agent loop.

Ask the model, run whatever tools it asks for, feed the results back, repeat until it stops asking. Everything interesting — which provider, which tools, who approves side effects — is injected, so the same loop drives the REPL, a one-shot run, and a batch worker.

Structs§

Agent
Budget
Per-run ceilings. Every None falls through to the agent’s own config, so a caller overrides only what it actually means to change.
Conversation
A conversation, and what has entered it.
RunContext
What the loop consults that is properly per-run rather than per-agent: what tools may touch, who approves the ones that aren’t read-only, and what this particular run is allowed to spend.
RunOutcome
Taint
What has entered this conversation so far.
ToolCallTrace
One tool call as it actually happened. The trace is what you grade a model on — final text alone can’t tell a lucky guess from correct tool use.

Enums§

AgentEvent
Everything the loop wants to tell an observer. The CLI renders these; a batch runner ignores all but the last.
Phase
Which half of the work a run is doing.
StopCause
Why the loop stopped. Completed is the model deciding it was done; everything else is the harness cutting it short.

Functions§

turns_phrase
“1 turn”, “3 turns”. These strings are read by people.