Skip to content

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.

From crates/agent_sdk/Cargo.toml:

FeaturePurpose
defaultagent-core
agent-coreRuntime-first base; enables a2a_protocol_core/core
a2a-serverA2A HTTP server transport (Spin on WASM, axum on native)
a2a-clientA2A HTTP client transport
fullBoth a2a-server and a2a-client with complete testing support
spec-compliantA2A specification compliance mode via a2a_protocol_core/spec-compliant
wasm-optimizedWASM optimization via a2a_protocol_core/wasm-optimized
file-handlingFile handling support via a2a_protocol_core/file-handling
llm-engineLLM tools-first orchestrator with llm_client and llm_tools
context-windowLLM context window management (token budgeting, history strategies); requires llm-engine
a2a-toolsA2A-native tools (agent/card/get + message/send exposed as LLM tools)
mcp-clientMCP tools: connect to external MCP servers. Native: rmcp (stdio + streamable HTTP). WASM: mcp_protocol (Streamable HTTP via spin-sdk)
mcp-e2eLive E2E tests against real MCP servers (never in default/CI)
config-loaderConfig loading via pf_config (JSON + env)
agent-observabilityObservability facade wiring; allows AgentBuilder to init observability
redis-storageRedis/Valkey task storage for native multi-replica agents
event-streamNative streaming adapters for Agent I/O and A2A SSE
agui-streamPublic AG-UI stream surface; built on top of event-stream
sub-agentsSub-agent delegation tools (native-only in v1)
test-supportTest-only engine seam accessors for cross-crate harnesses
auto-observabilityConvenience: config-loader + agent-observability
interactive-toolsTyped interaction contracts for reusable ask-question/confirmation flows
agui-agentCapability bundle: agent-core + llm-engine + agui-stream
a2a-agentCapability bundle: agent-core + llm-engine + a2a-server + a2a-client + event-stream
dual-agentCapability bundle: agui-agent + a2a-agent
pf-agentFull PromptFleet bundle: dual-agent + mcp-client + agent-observability

Core re-exports from agent_core:

  • AgentMessage, ContentPart, ConversationContext, Role, TaskPhase

Agent runtime:

  • Agent (aliased as AgentRuntime), AgentConfig (aliased as RuntimeConfig)
  • AgentBuilder — primary entrypoint: AgentBuilder::new("name") or AgentBuilder::from_config_path("agent.json")
  • AgentHost, AgentHostBuilder — native host composition for serving A2A + AG-UI
  • SkillEntryBuilder, SkillCall, SkillDefinition, SkillContext
  • HistoryPolicyConfig, HistoryPolicyMode, HistoryStrategyKind, MessageType

Services and utilities:

  • ServiceContainer — type-erased dependency injection
  • CallableSkill — trait for skill handlers
  • SdkError, SdkResult — error types
  • TimeoutPolicy — configurable timeout handling
  • InteractionKind, InteractionOption, InteractionRequest, InteractionResponse

Feature-gated modules:

  • a2a — A2A-specific types and composition helpers
  • agui — AG-UI streaming/composition helpers
  • streaming — 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::prelude re-exports the most common types

Constant:

  • SDK_VERSION — crate version from Cargo.toml
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(())
}

These bundle common feature combinations for convenience:

PresetIncludesUse case
agui-agentagent-core + llm-engine + agui-streamAG-UI streaming agent
a2a-agentagent-core + llm-engine + a2a-server + a2a-client + event-streamA2A-only agent
dual-agentagui-agent + a2a-agentAgent serving both A2A and AG-UI
pf-agentdual-agent + mcp-client + agent-observabilityFull PromptFleet agent with MCP and observability

Full API reference: cargo doc -p agent_sdk --no-deps --all-features