AI SDK v6
Stream chunks to Vercel AI SDK's useChat() — text, tool calls, and finish events.
Build agent capabilities once in Rust, tune and operate them live, and serve every client from the same runtime. Use direct runtime for in-process app flows or server mode for protocols, durable runs, and the admin console.
use awaken::contract::message::Message;
use awaken::engine::GenaiExecutor;
use awaken::registry_spec::{AgentSpec, ModelSpec};
use awaken::{AgentRuntimeBuilder, RunActivation};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let spec = AgentSpec::new("assistant")
.with_model_id("gpt-4o-mini")
.with_system_prompt("You are helpful.");
let rt = AgentRuntimeBuilder::new()
.with_agent_spec(spec)
.with_provider("openai", Arc::new(GenaiExecutor::new()))
.with_model(ModelSpec::new("gpt-4o-mini", "openai", "gpt-4o-mini"))
.build()?;
let req =
RunActivation::new("thread-1", vec![Message::user("Hello!")]).with_agent_id("assistant");
let out = rt.run_to_completion(req).await?;
println!("{}", out.response);
Ok(())
} Runtime mode keeps executable capability in Rust: tools, providers, state, plugins, and direct RunActivation execution. Server mode wraps it with durable runs, protocols, and managed config.
Tools as Tool / TypedTool impls with `schemars`-derived JSON Schema. State is typed: `StateKey` declares merge strategy + scope; commits are atomic per phase. Plugins hook the 9-phase loop by name.
Mutate through /v1/config/* (REST) or the admin console (UI) — both are server surfaces over the same registry snapshot. Existing runs keep their resolved spec; new runs pick up the edit.
The server translates each wire format into the same runtime event stream and run model. Switch clients without touching agent code.
Stream chunks to Vercel AI SDK's useChat() — text, tool calls, and finish events.
CopilotKit's <CopilotKit> drop-in for chat, generative UI, and HITL.
Agent-to-agent messaging — let other agents call yours as a remote sub-agent.
JSON-RPC 2.0 surface for MCP-compatible clients over the server route.
Agent Client Protocol stdio adapter from the server crate.
A React 19 SPA wired to the server APIs. Manage agents, models, providers, skills, MCP, traces, datasets, and eval runs from the same control plane.
Models, providers, prompts, permissions, MCP — edit the spec and the server publishes a registry snapshot for later runs.
The workspace runs with unsafe_code = "forbid". Public examples are covered by compile tests, doctests, and docs build checks.
Every run flows through nine typed phases. Plugins hook in by name. State commits atomically at the end of each round.
Each phase reads an immutable state snapshot and returns a typed mutation batch. commit applies the batch atomically — no partial writes, no surprise interleaving when tools run in parallel. The pure gate phase decides which tool calls to authorise before tool executes; permission, reminder, and HITL plugins all hook here.
Retry-After is honoured; checkpoints persist across process restarts. Seven typed extension surfaces, each gated by a cargo feature flag. Same trait Plugin + hooks the built-ins use — write your own with no special API.
Allow / Deny / Ask rules on tool name + args. Ask suspends the run for HITL via the mailbox.
Inject system or conversation-level messages when a tool call matches a pattern.
OpenTelemetry traces + metrics in GenAI semantic conventions. OTLP / file / in-memory.
Connect to any MCP server — its tools register as native Awaken tools.
Skill packages discovered and injected as a catalog — the LLM activates on demand.
Stream declarative UI via A2UI, JSON Render, and OpenUI Lang.
Hide large tool schemas behind a ToolSearch step; idle tools re-defer via a Beta usage model.
Same hooks: ToolGateHook, BeforeToolExecute, PluginConfigKey.