agent_sdk
Crate: agent_sdk · Path: crates/agent_sdk
Description (Cargo.toml): Runtime-first SDK for building PromptFleet agents with optional A2A and AG-UI adapters
The public foundation of the PromptFleet agent platform. Provides the agent runtime — skills, tools, services, protocol-neutral message types, and runtime event streams. Protocol adapters (A2A, AG-UI) are enabled through explicit features rather than defining the identity of the crate. The canonical model: build one Agent, compose A2A support with crate::a2a, compose AG-UI support with crate::agui.
Feature flags
Section titled “Feature flags”From crates/agent_sdk/Cargo.toml:
| Feature | Purpose |
|---|---|
default | agent-core |
agent-core | Runtime-first base; enables a2a_protocol_core/core |
a2a-server | A2A HTTP server transport (Spin on WASM, axum on native) |
a2a-client | A2A HTTP client transport |
full | Both a2a-server and a2a-client with complete testing support |
spec-compliant | A2A specification compliance mode via a2a_protocol_core/spec-compliant |
wasm-optimized | WASM optimization via a2a_protocol_core/wasm-optimized |
file-handling | File handling support via a2a_protocol_core/file-handling |
llm-engine | LLM tools-first orchestrator with llm_client and llm_tools |
context-window | LLM context window management (token budgeting, history strategies); requires llm-engine |
a2a-tools | A2A-native tools (agent/card/get + message/send exposed as LLM tools) |
mcp-client | MCP tools: connect to external MCP servers. Native: rmcp (stdio + streamable HTTP). WASM: mcp_protocol (Streamable HTTP via spin-sdk) |
mcp-e2e | Live E2E tests against real MCP servers (never in default/CI) |
config-loader | Config loading via pf_config (JSON + env) |
agent-observability | Observability facade wiring; allows AgentBuilder to init observability |
redis-storage | Redis/Valkey task storage for native multi-replica agents |
event-stream | Native streaming adapters for Agent I/O and A2A SSE |
agui-stream | Public AG-UI stream surface; built on top of event-stream |
sub-agents | Sub-agent delegation tools (native-only in v1) |
test-support | Test-only engine seam accessors for cross-crate harnesses |
auto-observability | Convenience: config-loader + agent-observability |
interactive-tools | Typed interaction contracts for reusable ask-question/confirmation flows |
agui-agent | Capability bundle: agent-core + llm-engine + agui-stream |
a2a-agent | Capability bundle: agent-core + llm-engine + a2a-server + a2a-client + event-stream |
dual-agent | Capability bundle: agui-agent + a2a-agent |
pf-agent | Full PromptFleet bundle: dual-agent + mcp-client + agent-observability |
Public API (from src/lib.rs)
Section titled “Public API (from src/lib.rs)”Core re-exports from agent_core:
AgentMessage,ContentPart,ConversationContext,Role,TaskPhase
Agent runtime:
Agent(aliased asAgentRuntime),AgentConfig(aliased asRuntimeConfig)AgentBuilder— primary entrypoint:AgentBuilder::new("name")orAgentBuilder::from_config_path("agent.json")AgentHost,AgentHostBuilder— native host composition for serving A2A + AG-UISkillEntryBuilder,SkillCall,SkillDefinition,SkillContextHistoryPolicyConfig,HistoryPolicyMode,HistoryStrategyKind,MessageType
Services and utilities:
ServiceContainer— type-erased dependency injectionCallableSkill— trait for skill handlersSdkError,SdkResult— error typesTimeoutPolicy— configurable timeout handlingInteractionKind,InteractionOption,InteractionRequest,InteractionResponse
Feature-gated modules:
a2a— A2A-specific types and composition helpersagui— AG-UI streaming/composition helpersstreaming— native streaming adapters (feature:event-stream)sub_agent— sub-agent delegation (feature:sub-agents)mcp_tools— MCP tools integration (feature:mcp-client)a2a_tools— A2A-native tool helpers (feature:a2a-tools)observability_runtime— SDK observability flush/runtime helpers (feature:agent-observability)wasm_kv_task_storage— WASM key-value task storage (feature:a2a-server)redis_task_storage— Redis/Valkey task storage (feature:redis-storage, native-only)
Macros:
a2a_serve!— zero-boilerplate macro that generates the complete#[http_component]function (WASM only, feature:a2a-server)
Prelude:
agent_sdk::preludere-exports the most common types
Constant:
SDK_VERSION— crate version fromCargo.toml
Example sketch
Section titled “Example sketch”use agent_sdk::{AgentBuilder, SdkResult};use serde_json::json;
fn main() -> SdkResult<()> { let mut agent = AgentBuilder::new("weather-agent")?.build()?;
agent .add_skill("get_weather") .handler(|params| async move { let location = params["location"].as_str().unwrap_or("unknown"); Ok(json!({"location": location, "temp": 22, "condition": "sunny"})) }) .register()?;
Ok(())}Capability bundles (presets)
Section titled “Capability bundles (presets)”These bundle common feature combinations for convenience:
| Preset | Includes | Use case |
|---|---|---|
agui-agent | agent-core + llm-engine + agui-stream | AG-UI streaming agent |
a2a-agent | agent-core + llm-engine + a2a-server + a2a-client + event-stream | A2A-only agent |
dual-agent | agui-agent + a2a-agent | Agent serving both A2A and AG-UI |
pf-agent | dual-agent + mcp-client + agent-observability | Full PromptFleet agent with MCP and observability |
Related guides
Section titled “Related guides”- LLM Client guide — using
llm-engineandcontext-window - LLM Tools guide — registering tools with
#[llm_tool] - A2A Serving guide — setting up A2A server transport
- AG-UI Streaming guide — streaming with
agui-stream - Sub-Agents guide — delegating to sub-agents
- MCP guide — connecting to MCP servers
- Configuration guide — using
config-loader - Observability guide — wiring
agent-observability - Interactive Tools guide — typed interaction contracts
- Skills guide — registering and composing skills
Full API reference: cargo doc -p agent_sdk --no-deps --all-features