BigPizzaV3/CodexPlusPlus · error · anyhow::Error
LLM Bridge 响应体过大
Error message
LLM Bridge 响应体过大
What it means
llm_proxy_value caps the upstream response at 4 MiB. It checks the Content-Length header first, then re-checks the actual byte count after reading, rejecting responses that exceed the limit either way.
Solutions
- Reduce max_tokens / prompt size so responses stay under 4 MiB
- Point the bridge at an endpoint returning concise output
- If large responses are required, raise the limit in llm_proxy_value (crates/codex-plus-core/src/routes.rs) — noting the safety tradeoff
Example fix
// before
let bytes = response.bytes().await?; // may exceed 4 MiB
// after
let bytes = response.bytes().await?;
if bytes.len() > 4 * 1024 * 1024 {
return Err(anyhow::anyhow!("LLM Bridge 响应体过大")); // keep, but client should request smaller outputs
} Defensive patterns
Strategy: try-catch
Try / catch
match llm_proxy_value(payload).await {
Err(e) if e.to_string().contains("响应体过大") => {
payload["body"] = serde_json::json!(shrink_request_for_smaller_reply(payload));
retry(payload)
}
other => other,
} Prevention
- Cap max_tokens in the upstream request so replies stay well under 4 MiB
- Avoid pointing the bridge at endpoints returning large non-LLM payloads
- If large replies are expected, raise the limit consciously rather than treating the error as transient
When it happens
Trigger: The proxied LLM endpoint returns a response whose Content-Length (or streamed body size) exceeds 4 * 1024 * 1024 bytes.
Common situations: Model returns an extremely long completion; upstream echoes large input; a non-LLM endpoint behind the bridge returns big JSON/binary payloads.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/1227b1bd245c24a7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/routes.rs:756
.redirect(reqwest::redirect::Policy::none())
.build()?;
let response = client
.post(url)
.headers(llm_proxy_headers(&payload)?)
.body(body)
.send()
.await?;
let http_status = response.status().as_u16();
let ok = response.status().is_success();
let content_type = response
.headers()
.get(reqwest::header::CONTENT_TYPE)
.and_then(|value| value.to_str().ok())
.unwrap_or_default()
.to_string();
if let Some(length) = response.content_length() {
if length > 4 * 1024 * 1024 {
anyhow::bail!("LLM Bridge 响应体过大");
}
}
let bytes = response.bytes().await?;
if bytes.len() > 4 * 1024 * 1024 {
anyhow::bail!("LLM Bridge 响应体过大");
}
let body_text = String::from_utf8_lossy(&bytes).to_string();
let body_json = if content_type
.split(';')
.next()
.map(str::trim)
.is_some_and(|value| value.eq_ignore_ascii_case("application/json"))
{
serde_json::from_slice::<Value>(&bytes).ok()
} else {
None
};
View on GitHub (pinned to b1ed92e5e4)