astrid-runtime/astrid · error · GatewayError::Internal
gateway is not wired to a live event bus; agent request stre
Error message
gateway is not wired to a live event bus; agent request stream unavailable
What it means
The GET agent requests SSE handler (get_requests) subscribes to agent request events on the event bus and streams them to the client. This error is thrown when GatewayState.event_bus is None, so there is no bus to subscribe to and no stream can be produced.
Source
Thrown at crates/astrid-gateway/src/routes/agent.rs:399
/// cannot spoof a grant prompt into a user's stream.
#[utoipa::path(
get,
path = "/api/agent/requests",
tag = "agent",
responses(
(status = 200, description = "Server-Sent Events stream of pending `approval` and `elicit` requests scoped to the authenticated principal. Starts with `event: ready`.", content_type = "text/event-stream"),
(status = 401, body = ErrorBody, description = "Missing / invalid bearer."),
(status = 500, body = ErrorBody, description = "Gateway not wired to a live event bus."),
)
)]
pub async fn get_requests(
State(state): State<Arc<GatewayState>>,
req: Request<axum::body::Body>,
) -> GatewayResult<Sse<impl Stream<Item = Result<Event, Infallible>>>> {
let caller = caller_from(&req)?.clone();
let Some(bus) = state.event_bus.clone() else {
return Err(GatewayError::Internal(anyhow::anyhow!(
"gateway is not wired to a live event bus; agent request stream unavailable"
)));
};
let conn_route_uuid = Uuid::new_v4();
let subscribe = |topic: &'static str| {
bus.subscribe_topic_routed(conn_route_uuid, topic, "gateway", "gateway::agent_requests")
};
let mut approval_rx = subscribe("astrid.v1.approval");
let mut elicit_rx = subscribe("astrid.v1.elicit");
let principal = caller.principal.to_string();
let stream = async_stream::stream! {
yield Ok::<Event, Infallible>(
Event::default()
.event("ready")
.data(serde_json::json!({ "principal": principal }).to_string())
);View on GitHub (pinned to affd8760f4)
Solutions
- Inject the live event bus into GatewayState during gateway construction and restart
- Enable the event bus subsystem in the deployment configuration
- If agent streaming is not offered, remove or gate the SSE endpoint for such deployments
- Verify the startup logs/health endpoint that the bus is connected before serving agent routes
Example fix
// before
let Some(bus) = state.event_bus.clone() else {
return Err(GatewayError::Internal(anyhow::anyhow!(
"gateway is not wired to a live event bus; agent request stream unavailable"
)));
};
// after: fail fast at startup, not per-request
let bus = config.event_bus.as_ref()
.ok_or_else(|| anyhow!("event bus required for agent routes"))?;
let state = GatewayState { event_bus: Some(bus.clone()) }; Defensive patterns
Strategy: validation
Validate before calling
// Verify bus availability before opening the SSE stream
pub fn agent_stream_available(state: &GatewayState) -> bool {
state.event_bus.is_some()
} Type guard
fn bus_of(state: &GatewayState) -> Option<Arc<EventBus>> {
state.event_bus.clone()
} Try / catch
match get_requests(state, req).await {
Err(GatewayError::Internal(e)) if e.to_string().contains("request stream unavailable") => {
StatusCode::SERVICE_UNAVAILABLE
}
other => other.map(Into::into),
} Prevention
- Wire the bus before mounting the requests SSE route; gate the route on bus presence
- Surface bus status in /healthz so operators notice before clients connect
- In bus-less deployments (tests/local), stub the SSE route instead of leaving it live
- Add an integration test asserting the requests stream works end-to-end when the bus is configured
When it happens
Trigger: Opening the agent request SSE stream when the gateway was built without an event bus (event_bus = None in GatewayState).
Common situations: Gateway launched in a mode without the agent runtime/event bus; misconfiguration that skips bus construction at startup; wiring regression after a refactor of GatewayState initialization; clients pointed at a deployment that intentionally has no agent support.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- gateway is not wired to a live event bus; agent invocation u
- gateway is not wired to a live event bus; audit stream unava
- gateway is not wired to a live event bus; live feed unavaila
- unexpected response from kernel: {other:?}
- bus admin request timed out after {:?} waiting for {want_res
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/61f8b005b566a016.
Report an issue: GitHub.