Skip to content

fix(agent): retry 413 after stripping vision payloads (#47339) - #56270

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-c655e92b
Jul 1, 2026
Merged

fix(agent): retry 413 after stripping vision payloads (#47339)#56270
teknium1 merged 1 commit into
mainfrom
hermes/hermes-c655e92b

Conversation

@teknium1

@teknium1 teknium1 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

A 413 no longer dead-ends a session that has browser_vision screenshots in context — when compression can't shrink the request further, Hermes evicts the base64 image payloads from tool messages and retries once.

Root cause (#47339): a 413 is a request-body byte-size limit, not a token limit. browser_vision stores 2-5MB base64 screenshots per call, so summarizing to ~44k tokens still leaves the HTTP body oversized and the turn dead-ends with "Payload too large and cannot compress further."

Changes

Validation

Result
tests/run_agent/test_413_compression.py 26/26 passed
Live E2E (real AIAgent, real 413 mid-loop) strip fired once w/ remember_model=False → image evicted, text kept → recovered in 2 calls; _no_list_tool_content_models stayed clean

Salvaged from #47397 by @Tranquil-Flow; placed onto main's current token-aware 413 recovery branch (the PR targeted the pre-token-aware version). Authorship preserved via rebase-merge.

Infographic

413 vision-payload recovery

When text compression can't reduce a 413 request further, evict base64
image parts from tool messages and retry once instead of dead-ending
with 'Payload too large and cannot compress further.'

A 413 is a request-body byte-size limit, not a token limit. browser_vision
screenshots (2-5MB base64 each) keep the HTTP body oversized even after
aggressive summarization. The strip pass passes remember_model=False so a
413 does not poison _no_list_tool_content_models — that set is for providers
that reject list-type tool content, a distinct failure mode.

Cherry-picked from #47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
@teknium1
teknium1 merged commit 122e5bc into main Jul 1, 2026
31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-c655e92b branch July 1, 2026 10:18
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/vision Vision analysis and image generation P2 Medium — degraded but workaround exists labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants