fix(agent): retry oversized resume on a fresh session with summarized history#3334
Draft
tatoalo wants to merge 2 commits into
Draft
fix(agent): retry oversized resume on a fresh session with summarized history#3334tatoalo wants to merge 2 commits into
tatoalo wants to merge 2 commits into
Conversation
… history When a resumed transcript no longer fits the context window, the API rejects every request including auto-compaction, so the resume continuation fails with "Prompt is too long" as a non-recoverable agent_error and the task can never be resumed again. Catch that specific failure, start a fresh session, and re-send the pending user message with the summarized history the non-native resume path already uses, instead of failing the run. Generated-By: PostHog Code Task-Id: c6065620-5694-4478-a20a-fec4ccde8f1a
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Move sessionMeta onto the active session, keep resumeState until the turn succeeds so the retry reuses the already-loaded conversation instead of re-downloading the run log, and reuse getErrorMessage from shared. Generated-By: PostHog Code Task-Id: c6065620-5694-4478-a20a-fec4ccde8f1a
2 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
When a resumed session's transcript no longer fits the model's context window, the API rejects every request — including the SDK's own auto-compaction — so the resume continuation fails with
Internal error: Prompt is too long. That is classified as a non-recoverableagent_error, the run dies before doing any work, and every subsequent resume of the task hits the same wall: the task is permanently stuck.Follow-up to #3331 (which makes hydration unlikely to produce an oversized transcript in the first place); this adds the safety net for any remaining path to an oversized resume.
Changes
handleTurnFailurebehavior.isPromptTooLongErrorpredicate inerror-classification.ts.How did you test this?
pnpm exec vitest run src/server/agent-server.test.ts— 101 passed.tsc --noEmiton the agent package.Automatic notifications
Created with PostHog Code