Expand description
Unified agent loop for both the fake provider and the Umans provider.
The loop runs on a background thread and sends AgentEvents through a
channel. The TUI drains them with try_recv, keeping the UI responsive.
§Lifecycle
RunHandle::spawnstarts a thread with a run configuration and cancellation token.- The run emits
Started, then streams reasoning/assistant deltas and tool-use requests. - Each tool-use request is dispatched via
tools::dispatch_fulland the result is emitted as aToolFinishedevent appended to the transcript. - For the Umans provider, tool results are fed back into the next turn:
after each dispatched tool batch, the assistant message (with
tool_useblocks) and the user message (withtool_resultblocks) are appended to the message history, and the provider is re-requested. - The loop enforces bounded tool-budget continuations to prevent recursive or unbounded tool-call loops while still allowing longer useful runs.
- Cancellation is cooperative: the loop checks the shared
CancelTokenbetween events, lines, and tool executions. When cancelled, it emitsAgentEvent::Cancelledand stops.
Structs§
- Retry
Policy - Bounded exponential retry policy for provider requests.
- RunHandle
- Handle for a single agent run: provider kind, config, prompt, and cancel.
Enums§
- Provider
Kind - Which provider drives this agent run.
- Tool
Permission Decision - Decision returned by an application-owned tool permission hook.
Functions§
- prompt_
expects_ workspace_ write - Best-effort classifier for prompts that should not finish without a workspace write. This is intentionally narrow: it requires both a file-ish reference and an edit/action verb.
Type Aliases§
- Tool
Execution Hook - Application-local execution override supplied to the provider-neutral run.
- Tool
Permission Hook - Application-local permission policy supplied to the provider-neutral run.