Panniantong/Agent-Reach · warning · ValueError
polish response exceeds 32 MiB limit
Error message
polish response exceeds 32 MiB limit
What it means
In scripts/transcribe_xiaoyuzhou.sh's embedded Python polish step: the Groq chat-completion response body exceeded 32 MiB (the script deliberately reads limit+1 bytes to detect overflow). A polish call should return a few KB of improved text; a 32 MiB body means something is pathologically wrong with the response, so it refuses to parse it.
Source
Thrown at agent_reach/scripts/transcribe_xiaoyuzhou.sh:326
body = json.dumps({
"model": MODEL,
"temperature": 0.2,
"max_completion_tokens": 8192,
"messages": [{"role": "user", "content": PROMPT_TMPL.format(text)}],
}).encode()
req = urllib.request.Request(
"https://api.groq.com/openai/v1/chat/completions",
data=body,
headers={
"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json",
"User-Agent": "agent-reach-xiaoyuzhou/1.0",
},
)
with urllib.request.urlopen(req, timeout=180) as r:
payload = r.read(32 * 1024 * 1024 + 1)
if len(payload) > 32 * 1024 * 1024:
raise ValueError("polish response exceeds 32 MiB limit")
resp = json.loads(payload)
return (
resp["choices"][0]["message"]["content"].strip(),
resp["choices"][0].get("finish_reason"),
)
def polish(text, depth=0):
try:
out, fr = call_groq(text)
except urllib.error.HTTPError as e:
sys.stderr.write(f"polish HTTP {e.code}: {e.read().decode(errors='replace')[:200]}\n")
return text # fallback to raw
except Exception as e:
sys.stderr.write(f"polish error: {e}\n")
return text
if fr != "length" or depth >= MAX_DEPTH:
return out
# 输出被截断:从中点切两半递归处理View on GitHub (pinned to 93ae1d18c3)
Solutions
- Split long transcripts into sections and polish each separately (polish already supports iterative depth, but call it on smaller inputs)
- Retry once — a runaway generation is usually transient
- If reproducible, reduce the input text size passed to call_groq (summarize or trim before polishing)
- Wrap the polish call in your own try/except ValueError to fall back to the raw transcript, mirroring the HTTPError fallback already in polish()
Example fix
# before (inside polish)
try:
out, fr = call_groq(text)
except urllib.error.HTTPError as e:
...
return text # fallback to raw
# ValueError from the 32 MiB check is uncaught -> script dies
# after
try:
out, fr = call_groq(text)
except (urllib.error.HTTPError, ValueError) as e:
sys.stderr.write(f"polish failed ({e}); using raw transcript\n")
return text # fallback to raw Defensive patterns
Strategy: fallback
Try / catch
# inside polish()
try:
out, fr = call_groq(text)
except (urllib.error.HTTPError, ValueError) as e:
sys.stderr.write(f"polish failed ({e}); using raw transcript\n")
return text # fallback to raw Prevention
- Cap the transcript size sent to polish(); split long episodes into sections
- Catch ValueError alongside HTTPError whenever calling call_groq directly
- Treat a >32 MiB LLM response as a runaway generation — retry once at most, then fall back to raw text
When it happens
Trigger: call_groq() posting an extremely large transcript to groq.com/openai/v1/chat/completions and the model/API returning a gigantic body (runaway repetition, degenerate output). Note polish() catches HTTPError but NOT this ValueError, so it propagates and kills the script.
Common situations: Very long episode transcripts (hours of text) sent in one polish request; a model looping/repeating tokens; upstream API misbehavior. Rare in practice — the 32 MiB cap is a defensive ceiling.
Related errors
- no provider key configured (need one of: {names})
- audio produced {len(chunks)} chunks; safety limit is {MAX_CH
- audio chunks total {total_chunk_bytes} bytes; safety limit i
- V2EX API response exceeds the 1 MiB safety limit
- {label} exceeds safety limit of {limit_mib:g} MiB
AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14).
Data as JSON: /api/errors/44d6f7f9d06be0ce.
Report an issue: GitHub.