Skip to main content

Crate agent

Crate agent 

Source
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.
AgentContext
AgentControl
Cloneable handle for listeners and other tasks: queue steering messages and abort the active run.
AgentLoopConfig
AgentOptions
AgentToolResult
What a tool returns. terminate on every result of a batch ends the run after it.
BeforeToolCallContext
What beforeToolCall sees: the call as the model sent it and its validated arguments.
BeforeToolCallResult
beforeToolCall’s decision: block fails the call with reason (default “Tool execution was blocked”); terminate marks that error result as ending the run.

Enums§

AgentEvent
QueueMode

Traits§

AgentTool
An executable tool. Err is a thrown error: it becomes an error result with the message as text.
StreamFn
StreamFn: one model response, events to sink, the final message returned (errors are messages).

Functions§

agent_loop
runAgentLoop: add prompts (after declaring tool changes) and run until the agent stops. Returns the new messages.

Type Aliases§

AgentMessage
A transcript message. Upstream allows app-specific message kinds; none exist in Rust yet.
BeforeToolCall
Runs after validation, before execution. Err is a thrown error: the call fails with the message as text.
MessageSource
Polls queued messages; called between turns.
ToolUpdate
Receives partial results while a tool runs (tool_execution_update).