Skip to content

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

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage-47397
Jul 1, 2026
Merged

fix(agent): retry 413 after stripping vision payloads (salvage #47397)#56293
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage-47397

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #47397 by @Tranquil-Flow (cherry-picked onto current main, authorship preserved). On an HTTP 413 that can't compress further, strips retained tool-message image payloads from the retry so an oversized vision request recovers instead of hard-failing (#47339).

The bug

Issue #47339: context compression doesn't evict image/vision payloads, so a request can 413 even at ~44k tokens. Confirmed still present on main: _strip_historical_media anchors on role=="user" images and the compressor only evicts tool-result image envelopes outside the protected tail — so a recent screenshot in the protected tail keeps its base64 bytes through every compression pass. When compression "can't reduce further," it still 413s.

The fix

At the terminal else-branch of the 413/payload_too_large recovery (reached only when compression didn't reduce the request), strip retained tool-message image payloads:

  • evicts image_url and input_image byte parts, preserves text/input_text (reassembled as joined text or a placeholder);
  • adds a remember_model=False kwarg so a 413 (a size problem) does not permanently mark a vision-capable model as unable to accept list-type tool content — that learning stays scoped to genuine provider list-content rejections.

Cluster context (#47339)

This is one of several approaches for #47339. It's the 413-retry-level backstop — complementary to, not competing with:

Verified as a sound standalone backstop: it addresses a real unfixed gap (protected-tail images survive compression) and doesn't collide with the shrink PRs. Ideally a compressor-level fix also lands so the tail case is handled before 413 fires; this remains valuable as the last-resort layer.

Review

Ran hermes-agent-dev + hermes-pr-review Phase 2c — 0 Critical. Strip logic handles both image shapes, preserves text, only fires on the last-resort path; the _no_list_tool_content_models learning-separation is real and tested (non-tautological — the test verifies retry #2's wire payload drops the image bytes present in #1).

Tests

pytest tests/run_agent/test_413_compression.py -q   # 25 passed (CI runs the full suite)

Supersedes #47397. Full credit to @Tranquil-Flow.

@kshitijk4poor
kshitijk4poor enabled auto-merge (rebase) July 1, 2026 10:30
@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 duplicate This issue or pull request already exists labels Jul 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #56270 — the same salvage of #47397 (retry 413 after stripping retained vision payloads, agent/conversation_loop.py + run_agent.py) was merged on 2026-07-01, so this fix is already on main. Related 413-image cluster on #47339: #47441, #47398, #52444, #47397.

@kshitijk4poor
kshitijk4poor merged commit 74809b4 into NousResearch:main Jul 1, 2026
31 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage-47397 branch August 5, 2026 07:09
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 duplicate This issue or pull request already exists 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