This repository was archived by the owner on Aug 6, 2026. It is now read-only.
fix(agent): treat gateway 413 as prompt-too-long - #3793
Merged
Conversation
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RA68K3mgc4P3X9jwPWVaFM
brandonleung
force-pushed
the
brandon/glm-413-prompt-too-long
branch
from
July 24, 2026 17:42
ca678e6 to
191d03b
Compare
brandonleung
marked this pull request as ready for review
July 24, 2026 17:45
Contributor
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
Contributor
|
Reviews (1): Last reviewed commit: "fix(agent): treat gateway 413 as prompt-..." | Re-trigger Greptile |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RA68K3mgc4P3X9jwPWVaFM
tatoalo
approved these changes
Jul 24, 2026
Contributor
Author
|
/trunk merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Cloud tasks running Cloudflare-hosted models (e.g.
@cf/zai-org/glm-5.2) through the LLM gateway fail permanently once a resumed transcript outgrows the model's context window: the gateway rejects every attempt with HTTP 413, the run ends in error, and each orchestrator restart replays the same oversized transcript indefinitely.Changes
The oversized-resume recovery already exists (
retryOversizedResumeOnFreshSessionrestarts the run on a fresh session with summarized history) but only triggered on Anthropic's "prompt is too long" phrasing.isPromptTooLongErrornow also matches the gateway's 413 shapes ("exceeded this model context window limit" and anyAPI Error: 413), so the recovery fires instead of the restart loop.agent_error, pinned by test, so transient-retry paths never burn attempts on it.How did you test this?
Each matcher has a unit case only it matches (deleting any one pattern fails a test), and the agent-server fresh-session-retry test drives the full wrapped gateway 413 message through the recovery end-to-end. vitest, tsc, and biome pass.
Automatic notifications