zeroclaw-labs/zeroclaw · error
NativeChatRequest should serialize to JSON
Error message
NativeChatRequest should serialize to JSON
What it means
Error "NativeChatRequest should serialize to JSON" thrown in zeroclaw-labs/zeroclaw.
Source
Thrown at crates/zeroclaw-providers/src/anthropic.rs:2584
"tool_choice": tool_choice.as_ref().and_then(|value| value.get("type")).and_then(|value| value.as_str()),
})),
"native thinking enabled; using non-streaming fallback to preserve signed thinking blocks"
);
let native_request = NativeChatRequest {
model: model.to_string(),
max_tokens: effective_max_tokens,
system: system_prompt,
messages,
temperature: effective_temperature,
tools: native_tools,
tool_choice,
stream: None,
thinking: thinking_config,
};
// Serialize eagerly so the request body is owned and `'static`
// across the async boundary.
let body = serde_json::to_value(&native_request)
.expect("NativeChatRequest should serialize to JSON");
let client = self.http_client();
let url = format!("{}/v1/messages", self.base_url);
let is_oauth = Self::is_setup_token(&credential);
return stream::once(async move {
let mut req = client
.post(&url)
.header("anthropic-version", "2023-06-01")
.header("content-type", "application/json")
.json(&body);
if is_oauth {
req = req
.header("Authorization", format!("Bearer {credential}"))
.header(
"anthropic-beta",
"claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14",
)
.header("anthropic-dangerous-direct-browser-access", "true");View on GitHub (pinned to 88bb9c8533)
Solutions
- This invariant failure indicates a serialization bug; report it with the request payload that triggered it.
- Validate the request fields against the Anthropic schema to find the value that breaks serialization.
When it happens
Trigger: Thrown at crates/zeroclaw-providers/src/anthropic.rs:2584 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/b7fc4b18d9dc84bd.
Report an issue: GitHub.