Hmbown/CodeWhale · error · anyhow::Error

runtime API turn response missing turn.id

Error message

runtime API turn response missing turn.id

What it means

Contract guard on the runtime API's turn creation response: the JSON accepted for a POST to /v1/threads/{thread_id}/turns is missing the /turn/id string field. Without a turn id the subsequent event stream cannot be correlated, so the malformed response is rejected rather than guessed at. The faulty input is the runtime's turn JSON.

Source

Thrown at crates/app-server/src/lib.rs:1180

        &mut self,
        thread_id: &str,
        input: &str,
        writer: &mut W,
        registration: Option<(TurnRegistry, String)>,
    ) -> Result<Value> {
        let turn = self
            .request_json(
                self.authed(
                    self.client
                        .post(format!("{}/v1/threads/{thread_id}/turns", self.base_url)),
                )
                .json(&json!({ "prompt": input })),
            )
            .await?;
        let turn_id = turn
            .pointer("/turn/id")
            .and_then(Value::as_str)
            .ok_or_else(|| anyhow!("runtime API turn response missing turn.id"))?
            .to_string();
        let response_id = format!("{thread_id}:{turn_id}");

        emit_stdio_event(
            writer,
            json!({
                "type": "response_start",
                "response_id": response_id,
            }),
        )
        .await?;

        // Publish the turn only for the streaming window, and take it back
        // before any `?` below: a turn that has already finished must never
        // look cancellable.
        if let Some((registry, key)) = registration.as_ref() {
            registry.lock().await.insert(
                key.clone(),

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Retry the turn; a truncated or malformed response can be transient
  2. Verify the runtime bridge version matches the app server (an older runtime may omit turn.id)
  3. Inspect the runtime's response via logs to confirm the turn object shape
  4. Restart or upgrade the runtime bridge if it consistently omits turn ids
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/app-server/src/lib.rs:1180 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/363a490a62257234. Report an issue: GitHub.