Expose HTTP SSE
Use this when clients consume run events over HTTP streaming.
Prerequisites
AgentOsis wired with tools and agents.ThreadReaderis available for query routes.ThreadReaderis wired to the same state store used by run/query APIs.
Endpoints
Run streams:
POST /v1/ag-ui/agents/:agent_id/runsPOST /v1/ai-sdk/agents/:agent_id/runsPOST /v1/runs
Run stream resume:
GET /v1/ai-sdk/agents/:agent_id/chats/:chat_id/stream
Query APIs:
GET /v1/threadsGET /v1/threads/summariesGET /v1/threads/:idGET /v1/threads/:id/messagesPATCH /v1/threads/:id/metadataDELETE /v1/threads/:idGET /v1/runsGET /v1/runs/:id
Steps
- Build router from route groups.
use std::sync::Arc;
use tirea_agentos_server::http::{self, AppState};
use tirea_agentos_server::protocol;
let app = axum::Router::new()
.merge(http::health_routes())
.merge(http::thread_routes())
.merge(http::run_routes())
.merge(protocol::a2a::http::well_known_routes())
.nest("/v1/ag-ui", protocol::ag_ui::http::routes())
.nest("/v1/ai-sdk", protocol::ai_sdk_v6::http::routes())
.nest("/v1/a2a", protocol::a2a::http::routes())
.with_state(AppState {
os: Arc::new(agent_os),
read_store,
mailbox_service,
});
- Call AI SDK v6 stream.
curl -N \
-H 'content-type: application/json' \
-d '{"id":"thread-1","messages":[{"role":"user","content":"hello"}],"runId":"run-1"}' \
http://127.0.0.1:8080/v1/ai-sdk/agents/assistant/runs
- Call AG-UI stream.
curl -N \
-H 'content-type: application/json' \
-d '{"threadId":"thread-2","runId":"run-2","messages":[{"role":"user","content":"hello"}],"tools":[]}' \
http://127.0.0.1:8080/v1/ag-ui/agents/assistant/runs
- Query persisted data.
curl 'http://127.0.0.1:8080/v1/threads/thread-1/messages?limit=20'
curl 'http://127.0.0.1:8080/v1/runs?thread_id=thread-1&limit=20'
Verify
- Stream routes return
200withcontent-type: text/event-stream. - AI SDK stream returns
x-vercel-ai-ui-message-stream: v1anddata: [DONE]trailer. - AG-UI stream includes lifecycle events (for example
RUN_STARTEDandRUN_FINISHED). GET /v1/runs/:idreturns run projection metadata.
Common Errors
400for payload validation (id,threadId,runId, or message/decision rules).404for unknownagent_id.- Run/A2A routes fail with internal error when run service is not initialized.
Related Example
examples/ai-sdk-starter/README.mdexercises AI SDK HTTP streaming end to endexamples/copilotkit-starter/README.mdexercises AG-UI streaming end to end
Key Files
crates/tirea-agentos-server/src/http.rscrates/tirea-agentos-server/src/protocol/ag_ui/http.rscrates/tirea-agentos-server/src/protocol/ai_sdk_v6/http.rsexamples/src/starter_backend/mod.rs