AI SDK v6
Stream chunks to Vercel AI SDK's useChat() — text, tool calls, and finish events.
Keep tools, state, providers, and plugins in production Rust code. Tune prompts, models, permissions, skills, and eval loops through managed config and the Admin Console — without rebuilding the runtime.
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(())
} The Admin Console is the tuning surface over the server APIs: edit agents, prompts, models, permissions, skills, MCP, traces, datasets, and eval runs from one control plane.
Edit through the Admin Console or /v1/config/*. The server validates the draft, publishes a registry snapshot, and the next run resolves against it.
Tune with evidence: replay fixtures, score outputs, inspect diffs, then publish the next agent spec.
Config revisions and audit restore make prompt/model/policy tuning reviewable instead of hidden in deploy scripts.
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.
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. Built-in and companion extension crates expose the same trait Plugin + hook model you use for custom capability. Opt in only to the surfaces your agent needs.
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.