BigPizzaV3/CodexPlusPlus · error · anyhow::Error
LLM Bridge 请求体过大
Error message
LLM Bridge 请求体过大
What it means
llm_proxy_value caps the forwarded request body at 1 MiB (1_048_576 bytes) and bails when body.len() exceeds it. The LLM Bridge proxies a caller-supplied body to a remote endpoint; oversized bodies would balloon memory and upstream latency, so they are rejected before the reqwest call.
Solutions
- Trim/summarize the request body below 1 MiB before sending
- Offload large content to a URL/file reference the downstream API can fetch
- Split the request into multiple smaller bridge calls
Example fix
// before body = build_body(all_messages); // 2 MB send_bridge(body); // after body = build_body(truncate_messages(all_messages, MAX_BODY = 1_048_576)); send_bridge(body);
Defensive patterns
Strategy: validation
Validate before calling
fn body_within_limit(body: &str) -> bool { body.len() <= 1_048_576 } Try / catch
match llm_proxy_value(payload).await {
Err(e) if e.to_string().contains("请求体过大") => {
payload["body"] = serde_json::json!(truncate(payload["body"].as_str().unwrap_or_default()));
retry(payload)
}
other => other,
} Prevention
- Check body.len() before building the bridge payload
- Truncate or summarize long conversation history
- Stream large attachments via URLs instead of inlining them
When it happens
Trigger: Sending a bridge payload whose "body" string exceeds 1,048,576 bytes.
Common situations: Attaching very long conversation history or large documents in a single request; embedding base64 files in the body; a client batching many messages without truncation.
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/8d9709958c3b8822.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/routes.rs:733
.map(str::trim)
.filter(|value| !value.is_empty())
.unwrap_or("POST");
if !method.eq_ignore_ascii_case("POST") {
anyhow::bail!("LLM Bridge 仅支持 POST 请求");
}
let timeout_ms = payload
.get("timeout_ms")
.and_then(Value::as_u64)
.unwrap_or(60_000)
.clamp(1_000, 60_000);
let body = payload
.get("body")
.and_then(Value::as_str)
.unwrap_or_default()
.to_string();
if body.len() > 1_048_576 {
anyhow::bail!("LLM Bridge 请求体过大");
}
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_millis(timeout_ms))
.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())View on GitHub (pinned to b1ed92e5e4)