Hmbown/CodeWhale · error
runtime API turn response missing turn.id
Error message
runtime API turn response missing turn.id
What it means
Thrown while parsing the runtime API's turn-start HTTP response. The code extracts the turn identifier from the JSON pointer `/turn/id` and requires it to be a string; if the pointer is absent, null, or not a string, it cannot construct the `thread_id:turn_id` response key and raises this error. It guards against the upstream runtime returning a malformed or incomplete turn payload.
Solutions
- Log/capture the full raw response body to see what the runtime actually returned for `/turn/id`.
- Check that the runtime API server version matches the version this client was built against.
- Verify the endpoint is the turn-creation route and not an error or fallback route.
- Add a guard that validates `turn.id` presence and reports the payload before constructing the response id.
Example fix
// before
let turn_id = turn.pointer("/turn/id").and_then(Value::as_str).ok_or_else(|| anyhow!("runtime API turn response missing turn.id"))?;
// after
let turn_id = turn.pointer("/turn/id").and_then(Value::as_str)
.ok_or_else(|| anyhow!("runtime API turn response missing turn.id: {}", serde_json::to_string(&turn).unwrap_or_default()))?; Defensive patterns
Strategy: validation
Validate before calling
if turn.pointer("/turn/id").and_then(Value::as_str).is_none() {
// reject/log payload before calling the turn-start API
} Type guard
fn has_turn_id(v: &Value) -> bool { v.pointer("/turn/id").map_or(false, Value::is_string) } Try / catch
match start_turn(...).await {
Err(e) if e.to_string().contains("missing turn.id") => { /* log raw response, check runtime version */ }
other => other?,
} Prevention
- Pin and verify the runtime API version on both sides
- Validate response schemas in integration tests against a live mock
- Include the raw payload in error messages for diagnosability
When it happens
Trigger: The POST that starts a turn returns JSON without a string at `turn.id` — e.g. the runtime accepted the request but the response shape changed, or an error was returned as a 200 with a different body.
Common situations: Runtime API version drift changing the response schema; server-side errors returning partial payloads; proxies or gateways rewriting responses; hitting the wrong endpoint.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- runtime API thread response missing id
- sub-agent transcript record is missing its message
- agy OAuth token JSON carries no access token member
- Antigravity cloud-code SSE is not JSON
- Burn rate is optional. When set, it must be a positive $/hr.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/363a490a62257234.
Report an issue: GitHub.
Appendix: source
Thrown at crates/app-server/src/lib.rs:1798
}
request["images"] = json!(images);
}
if let Some(limit) = max_output_tokens {
request["maxOutputTokens"] = json!(limit);
}
let turn = self
.request_json(
self.authed(
self.client
.post(format!("{}/v1/threads/{thread_id}/turns", self.base_url)),
)
.json(&request),
)
.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}");
if let Some(transcript) = transcript.as_deref_mut() {
transcript.model = turn
.pointer("/thread/model")
.and_then(Value::as_str)
.map(str::to_string);
transcript.events.push(EventFrame::ResponseStart {
response_id: response_id.clone(),
});
}
emit_stdio_event(
writer,
json!({
"type": "response_start",
"response_id": response_id,View on GitHub (pinned to 73e0f67d83)