Expand description
§Module: Agent
§Responsibility
Provides a ReAct (Thought-Action-Observation) agent loop with pluggable tools.
Mirrors the public API of wasm-agent.
§Guarantees
- Deterministic: the loop terminates after at most
max_iterationscycles - Non-panicking: all operations return
Result - Tool handlers support both sync and async
Fnclosures
§NOT Responsible For
- Actual LLM inference (callers supply a mock/stub inference fn)
- WASM compilation or browser execution
- Streaming partial responses
Structs§
- Agent
Config - Configuration for the ReAct agent loop.
- InMemory
Tool Cache - A simple in-memory
ToolCachebacked by aMutex<HashMap>. - Message
- A single message in the conversation history.
- ReAct
Loop - The ReAct agent loop.
- ReAct
Step - A single ReAct step: Thought → Action → Observation.
- Tool
Registry - Registry of available tools for the agent loop.
- Tool
Spec - Describes and implements a single callable tool.
Enums§
- Action
- A parsed action from a ReAct step.
- Agent
Error - Agent-specific errors, mirrors
wasm-agent::AgentError. - Role
- Role of a message in a conversation.
Traits§
- Observer
- Hook trait for observing agent loop events.
- Tool
Cache - Cache for tool call results.
- Tool
Validator - Declarative argument validator for a
ToolSpec.
Functions§
- make_
action_ hook - Create an
ActionHookfrom a plainasync fnor closure. - parse_
react_ step - Parses a ReAct response string into a
ReActStep.
Type Aliases§
- Action
Hook - Async hook called before each tool action. Return
trueto proceed,falseto block. - Async
Tool Future - A pinned, boxed future returning a
Value. Used for async tool handlers. - Async
Tool Handler - An async tool handler closure.
- Async
Tool Result Future - A pinned, boxed future returning
Result<Value, String>. Used for fallible async tool handlers.