fix: classify context-overflow 401 responses correctly - #2655
Conversation
🦋 Changeset detectedLatest commit: 8eeac58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc3ebf04a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| (error.code === ErrorCodes.AUTH_LOGIN_REQUIRED || | ||
| error.code === ErrorCodes.PROVIDER_AUTH_ERROR) | ||
| error.code === ErrorCodes.PROVIDER_AUTH_ERROR || | ||
| error.code === ErrorCodes.CONTEXT_OVERFLOW) |
There was a problem hiding this comment.
Avoid re-running failed compactions as fresh overflows
When a scheduled auto-compaction in the beforeStep path itself exhausts its shrink attempts with context.overflow, rethrowing that provider error unchanged lets the loop-level full-compaction error handler match it as a new recoverable overflow (shouldRecoverFromContextOverflow accepts any coded context.overflow) and start another auto-compaction instead of failing immediately. That repeats an already-failed summarizer request and can add another expensive provider round-trip before the turn fails; the legacy path tags these as compaction_context_overflow, so v2 should similarly mark or guard compaction-origin overflows while preserving the public code/message.
Useful? React with 👍 / 👎.
Related Issue
Resolve #2613
Problem
Some managed models return HTTP 401 when a request exceeds the model context window. The provider message identifies the context limit, but both engines treated every 401 as an authentication failure, retried with a refreshed OAuth token, and ACP ultimately reported
Authentication required.What changed
supports only 256K context, before generic 401 authentication handling in both engines.context.overflowthrough failed compaction and expose its actionable provider message to ACP clients.Validation
kosong,agent-core,agent-core-v2,kimi-code-sdk, andacp-adapter.agent-core-v2import-boundary check passed.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.