Expand description
Rust port of Ultron’s packages/agent loop (agent-loop.ts) and Agent (agent.ts): turns over a streaming
function, tool execution, the steering queue, abort, and the emitted AgentEvent stream.
Evidence: fixtures/generate.mjs drives the TypeScript Agent with the TypeScript faux provider and records every
provider call and agent event; tests/loop.rs replays the provider events here and compares the agent events.
Structs§
- Agent
Agent: owns the transcript and tools, runs prompts through the loop, and keeps state from the events.- Agent
Context - Agent
Control - Cloneable handle for listeners and other tasks: queue steering messages and abort the active run.
- Agent
Loop Config - Agent
Options - Agent
Tool Result - What a tool returns.
terminateon every result of a batch ends the run after it. - Before
Tool Call Context - What
beforeToolCallsees: the call as the model sent it and its validated arguments. - Before
Tool Call Result beforeToolCall’s decision:blockfails the call withreason(default “Tool execution was blocked”);terminatemarks that error result as ending the run.
Enums§
Traits§
- Agent
Tool - An executable tool.
Erris a thrown error: it becomes an error result with the message as text. - Stream
Fn StreamFn: one model response, events tosink, the final message returned (errors are messages).
Functions§
- agent_
loop runAgentLoop: addprompts(after declaring tool changes) and run until the agent stops. Returns the new messages.
Type Aliases§
- Agent
Message - A transcript message. Upstream allows app-specific message kinds; none exist in Rust yet.
- Before
Tool Call - Runs after validation, before execution.
Erris a thrown error: the call fails with the message as text. - Message
Source - Polls queued messages; called between turns.
- Tool
Update - Receives partial results while a tool runs (
tool_execution_update).