[proxy::response_processor] [Claude] stream error - Claude Code
Quick fix
A stream decode error or timeout proxying Claude Code loses logs or records 0 tokens. Fix the model extraction fallback to show the right model.
Symptom
Section titled “Symptom”[2026-02-24][08:25:52][ERROR][cc_switch_lib::proxy::response_processor] [Claude] 流错误: error decoding response body[2026-02-24][08:25:52][ERROR][cc_switch_lib::proxy::response_processor] [Claude] stream error: error decoding response body
When cc-switch proxies Claude Code, an upstream error decoding response body or a 120-second idle timeout leaves response_processor unable to collect the complete stream events. That produces systematic missing requests in proxy_request_logs (roughly 7-25%), or records with all tokens and cost at 0.
Because the stream is truncated, claude_model_extractor also cannot extract the mapped model actually used (glm-5.1, for example) from message_delta, and falls back wrongly to the original request model name (claude-opus-4-8).
Open src-tauri/src/proxy/handler_config.rs in the cc-switch source.
Modify the claude_model_extractor function to extract the real model name from the message_start event before falling back to request_model.
// src-tauri/src/proxy/handler_config.rsfn claude_model_extractor(events: &[Value], request_model: &str) -> String {if let Some(usage) = TokenUsage::from_claude_stream_events(events) {if let Some(model) = usage.model {return model;}}events.iter().find_map(|e| {if e.get("type")?.as_str()? == "message_start" {e.get("message")?.get("model")?.as_str()} else {None}}).unwrap_or(request_model).to_string()}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
- Why do some requests in the database have 0 tokens and 0 cost?
- When a streaming response hits the 120-second idle timeout or a decode error, cc-switch cannot collect the complete SSE events carrying usage, so tokens and cost record as 0.
- Do the missing log entries affect what I am actually billed?
- No. The request reached the provider successfully and was billed; only the local cc-switch database failed to record the usage.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.