Skip to content

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

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/47339-vision-payload-compression
Closed

fix(agent): retry 413 after stripping vision payloads (#47339)#47397
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/47339-vision-payload-compression

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

Summary

  • Retry 413 recovery by stripping retained tool-message image payloads when context compression cannot reduce the request further.
  • Preserve text context from the tool result while evicting image_url / input_image bytes from the retry payload.
  • Keep the existing provider-list-content rejection learning separate from 413 payload-size recovery so a too-large request does not permanently mark a vision-capable model as unable to accept list-type tool content.

Verification

  • /Users/evinova-self/.hermes/hermes-agent/venv/bin/python3 -m pytest tests/run_agent/test_413_compression.py -v -o "addopts=" --tb=short — 25 passed, 1 warning.
  • Regression red proof from build artifacts: the new production-path test failed on upstream/main with Payload too large and cannot compress further before the fix.

Competitor / duplicate check

Auto-published by Moonsong via Path B automated pipeline.

@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 P1 High — major feature broken, no workaround labels Jun 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #47398, #42509, #37412 (all fix #47339 — context compression not evicting image/vision payloads, leading to HTTP 413).

Same goal, different mechanism: this PR strips retained tool-message image payloads at the 413 retry-recovery level (conversation_loop.py / run_agent.py), while #47398 fixes the root cause in _strip_historical_media (context_compressor.py) so tool-result _multimodal envelopes are evicted during compression. #42509 and #37412 take an inline-image-shrink approach. Not a duplicate — these are complementary/competing approaches for the maintainer to choose between.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jun 21, 2026
teknium1 pushed a commit that referenced this pull request Jul 1, 2026
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 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Merged via #56270 (commit 122e5bc) with your authorship preserved via rebase-merge.

Your fix was cherry-picked onto current main — the 413 recovery path had moved to a token-aware compression check since you opened this, so the strip+retry was placed onto that current else branch. Live E2E confirmed the production path: a real 413 mid-loop with a browser_vision screenshot triggers the eviction (remember_model=False, no false poisoning of the list-content set) and recovers. Thanks for the clean, well-reasoned fix!

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Superseded by #56293, which carries your commit verbatim (authorship preserved) rebased onto current main. Verified as a sound standalone 413 backstop for #47339 — the root cause (protected-tail images surviving compression) is still unfixed on main; your strip handles both image_url/input_image shapes, preserves text, and the remember_model=False learning-separation is real and tested. Complementary to the shrink PRs (#42509/#37412) and the closed root-cause #47398, not a duplicate. Phase 2c review: 0 Critical. Full credit to you.

waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
Jasper6439 pushed a commit to Jasper6439/hermes-agent that referenced this pull request Jul 5, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…7339)

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 NousResearch#47397 by Tranquil-Flow; placed onto main's current
token-aware 413 recovery else branch.
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 P1 High — major feature broken, no workaround sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants