Expand description
Commonly used imports for building agents and workflows.
Structs§
- Agent
- The primary concrete agent: pairs a chat client with instructions, default options, tools, context providers, and middleware.
- Agent
Builder - Builder for
Agent. - Agent
Context - Context flowing through the agent middleware pipeline.
- Agent
Response - A full response from an agent run.
- Agent
Response Update - A single streaming chunk from an agent run.
- Agent
RunOptions - Per-run option overrides for a single
SupportsAgentRun::run_with_options/SupportsAgentRun::run_streamcall, merged over the agent’s build-time defaults. - Agent
Session - A conversation session: a lightweight identity + state container.
- Approx
Tokenizer - A dependency-free default tokenizer using a ~4-characters-per-token
heuristic. Mirrors upstream’s
CharacterEstimatorTokenizer. - AsTool
Options - Options for
Agent::as_tool. - Chat
Context - Context flowing through the chat middleware pipeline.
- Chat
Options - Common per-request settings for a chat/AI service.
- Chat
Response - A full (non-streaming) response from a chat client.
- Chat
Response Update - A single streaming chunk from a chat client.
- Compaction
Provider - A
ContextProviderthat compacts the accumulated message list — typically the run’s history, once aHistoryProviderhas prepended it inbefore_run— down to fit aCompactionStrategy’s constraint before it reaches the model. Rust equivalent of (a subset of) upstream’sCompactionProvider(see module docs andUPSTREAM_DRIFT.md§9). - Concurrent
Builder - Builder for a concurrent fan-out/fan-in over agents. Rust analogue of
ConcurrentBuilder. - Embedding
- A single embedding vector with metadata.
- Embedding
Generation Options - Common request settings for embedding generation.
- File
Checkpoint Storage - File-based checkpoint storage: one JSON file per checkpoint in a directory.
- File
History Provider - A
HistoryProviderthat persists to a JSON file on disk, loading any existing history frompathon construction and rewriting the whole file after every successful run. - Finish
Reason - Reason a chat response finished. Open value wrapper, like
FinishReason. - Function
Approval Request Content - A request to the user to approve a function call (human-in-the-loop).
- Function
Approval Response Content - A user’s response approving or denying a function call.
- Function
Call Content - A request from the model to call a tool/function.
- Function
Invocation Config - Configuration for the automatic function-invocation loop.
- Function
Invocation Context - Context flowing through the function middleware pipeline.
- Function
Invoking Chat Client - Wraps a
ChatClientto automatically execute local tool calls in a loop, mirroringuse_function_invocation. - Function
Result Content - The result of executing a tool/function.
- Function
Tool - A concrete, locally executable tool built from a closure.
- Generated
Embeddings - A batch of generated embeddings plus usage metadata.
- Group
Chat Builder - Builder for a group chat workflow. Rust analogue of
GroupChatBuilder. - Group
Chat State - A snapshot of orchestration state handed to a
GroupChatManagerfor its speaker-selection decision. Rust analogue ofGroupChatStateSnapshot. - Handoff
Builder - Builder for a handoff workflow. Rust analogue of
HandoffBuilder. - InMemory
Checkpoint Storage - In-memory checkpoint storage for testing and development.
- InMemory
History Provider - In-memory
HistoryProvider: keeps history in anArc<Mutex<Vec<Message>>>, shared across clones. - Live
Tool List - The live, mutable tool list of an in-flight agent run (progressive tool exposure).
- Magentic
Builder - Builder for a Magentic workflow. Rust analogue of
MagenticBuilder. - Magentic
Context - Mutable state threaded through the Magentic manager and orchestrator. Rust
analogue of
MagenticContext. - Magentic
Plan Review Request - The payload of the request-info event emitted when plan review is enabled
and the orchestrator needs a human decision on the task ledger. Rust
analogue of Python’s
_MagenticHumanInterventionRequestnarrowed to itskind=PLAN_REVIEWfields (task_text,facts_text,plan_text,round_index). - Magentic
Stall Intervention Request - The payload of the request-info event emitted when stall intervention is
enabled and the round loop detects a stall. Rust analogue of Python’s
_MagenticHumanInterventionRequestnarrowed to itskind=STALLfields (stall_count,max_stall_count,task_text,facts_text,plan_text,last_agent,stall_reason), plusround/resets_so_farfor context. - Message
- A single chat message: an author role plus an ordered list of content items.
- Middleware
Pipeline - A pipeline of middleware of a single category.
- Next
- The continuation passed to a
Middleware. CallingNext::runinvokes the remaining middleware and, finally, the terminal handler. - Observability
Config - Observability configuration read from the process environment, mirroring
(a subset of) Python’s
ObservabilitySettings(observability.py:347-394). - Observable
Chat Client - A
ChatClientdecorator that emits achatspan per request following the OpenTelemetry GenAI semantic conventions. - OpenAI
Chat Client - An OpenAI Responses API chat client (
POST /v1/responses). - OpenAI
Chat Completion Client - An OpenAI (or OpenAI-compatible) chat client.
- OpenAI
Embedding Client - An OpenAI (or OpenAI-compatible) embeddings client.
- Request
Info Executor - A built-in node that surfaces incoming messages as external requests.
- Retry
Policy - Policy controlling
RetryingChatClientbackoff. - Retrying
Chat Client - A
ChatClientdecorator that retries transient failures with exponential backoff, honoring a serverRetry-Afterwhen present. - Role
- The role of a message author.
- Secret
String - A string wrapper that masks its value when printed via
DebugorDisplay, to prevent secrets (API keys, tokens, passwords, …) from accidentally ending up in logs or error messages. - Selective
Tool Result - Replace the payload of
Content::FunctionResult(tool-result) content in all but the lastkeep_lastmessages that carry tool results — they are the bulkiest and least useful once stale. Text and other content is left intact. - Sequential
Builder - Builder for a sequential pipeline of agents. Rust analogue of
SequentialBuilder. Each participant sees the running conversation and appends its reply; the final conversation is yielded as output. - Session
Context - Per-invocation context a provider contributes to a run. Providers mutate this in place in before_run. Rust equivalent of upstream SessionContext.
- Session
State - The free-form state bag of an
AgentSession, shared by reference across clones. - Shared
State - A thread-safe, async, string→JSON store shared by all executors in a run.
- Skill
- A named, progressive-disclosure capability package.
- Skills
Provider - A
ContextProviderthat attaches a set ofSkills to an agent run with progressive disclosure. - Sliding
Window - Keep leading system message(s) + the last
windownon-system messages. Mirrors upstream’sSlidingWindowstrategy. - Standard
Magentic Manager - The standard LLM-driven manager. Rust analogue of
StandardMagenticManager. - Text
Content - Plain text content.
- Token
Budget - Keep leading system message(s), then walk from the newest message
backward accumulating token counts, keeping messages until adding the
next would exceed
max_tokens. Returns the kept messages in original order. Mirrors upstream’sContextWindow/token-budget strategy. - Tool
Definition - A uniform, cloneable descriptor of a tool passed via
ChatOptions::tools. - Truncation
- Keep the most recent
max_messages, always preserving any leading system message(s) at the front. Mirrors upstream’sTruncationstrategy. - Usage
Details - Token usage counts for a request/response.
- Workflow
- A built, runnable workflow graph.
- Workflow
Agent - An
SupportsAgentRunthat wraps aWorkflowand exposes it through the agent interface. Rust analogue ofWorkflowAgent. - Workflow
Builder - Fluent builder for a
Workflow. Rust equivalent ofWorkflowBuilder. - Workflow
Context - Collects the effects an executor produces while handling a message:
messages to send downstream, workflow outputs, custom events, info
requests, and access to run-scoped
SharedState. - Workflow
Executor - An
Executorthat runs a childWorkflow, enabling hierarchical composition. - Workflow
Run - A live workflow run: owns the pending message queue, fan-in buffers, iteration count, shared state, and outstanding requests, so a run can pause (awaiting external input) and later resume.
Enums§
- Approval
Mode - Whether a call to a tool must be approved by a human before it runs.
- Content
- The unified content union, discriminated by the
typetag. - Error
- The primary error type for the agent framework.
- Group
Chat Directive - An instruction emitted by a
GroupChatManager: either route to a participant, or finish the conversation. Rust analogue ofGroupChatDirective. - Handoff
Interaction Mode - Whether the workflow pauses for fresh user input between agent turns.
- Magentic
Plan Review Decision - A human’s decision on a
MagenticPlanReviewRequest. Rust analogue of Python’s_MagenticHumanInterventionReplynarrowed to plan review, withMagenticHumanInterventionDecision.{APPROVE,REVISE}as the two variants. - Magentic
Stall Intervention Decision - A human’s decision on a
MagenticStallInterventionRequest. Rust analogue of Python’s_MagenticHumanInterventionReplynarrowed to the stall subset ofMagenticHumanInterventionDecision(CONTINUE/REPLAN/GUIDANCE). - McpApproval
Mode - The approval gate configured on a hosted MCP connector – i.e. how the
service itself decides whether a call to one of its MCP tools needs human
sign-off before it runs. Set via
ToolDefinition::mcp_approval_mode. - Response
Format - The requested structured-output format for a response.
- RetryOn
- Which errors a
RetryPolicyconsiders retryable. - Tool
Kind - The category of a tool as advertised to the service.
- Tool
Mode - If and how tools may be used for a request. Mirrors the Python
ToolMode. - Workflow
Event - An event observed while a workflow runs.
- Workflow
RunState - The run state of a workflow, mirroring Python’s
WorkflowRunState.
Traits§
- Chat
Client - The interface every chat client implements.
- Checkpoint
Storage - Storage backend for workflow checkpoints.
- Compaction
Strategy - A strategy that reduces a message list to fit some constraint.
- Context
Provider - A source of per-invocation context (memory, RAG, etc.). Upstream renamed invoking/invoked -> before_run/after_run and REMOVED thread_created. before_run mutates the SessionContext in place instead of returning a Context.
- Embedding
Client - The interface every embedding client implements.
- Executor
- A node in a workflow graph.
- Group
Chat Manager - The decision-making interface for a group chat. Implementations pick the
next speaker or finish the conversation. Rust analogue of the manager
callable /
set_manageragent in Python. - History
Provider - A
ContextProviderthat also manages conversation history. - Magentic
Manager - The Magentic manager interface: planning, replanning, progress evaluation,
and final-answer synthesis. Rust analogue of
MagenticManagerBase. - Middleware
- A middleware that transforms a context of type
C. - Supports
Agent Run - The common interface implemented by all agents.
- Tokenizer
- Counts tokens for a piece of text. Rust equivalent of upstream
TokenizerProtocol. - Tool
- An executable tool the framework can invoke locally.
- Tool
Source - A dynamic source of tools, resolved fresh on every agent run instead of being frozen into the agent’s tool list at build time.
- Workflow
Agent Ext - Extension trait adding
Workflow::as_agentso a built workflow can be exposed as anSupportsAgentRunfluently.
Functions§
- compact
- Compact
messageswithstrategyandtokenizer. - hosted_
code_ interpreter - Construct a hosted code-interpreter tool marker.
- hosted_
file_ search - Construct a hosted file-search tool marker.
- hosted_
image_ generation - Construct a hosted image-generation tool marker.
- hosted_
mcp - Construct a hosted MCP tool marker.
- hosted_
web_ search - Construct a hosted web-search tool marker.
- load_
setting - Resolve a single setting value using the same precedence as upstream’s
load_settings:
Type Aliases§
- Agent
RunStream - A boxed stream of agent run updates.
- Agent
Tool Stream Callback - A callback receiving each
AgentResponseUpdatestreamed by an agent running as a tool — seeAsToolOptions::stream_callback. - Chat
Stream - A boxed stream of streaming chat updates.
- Result
- The result type used throughout the framework.