fix(agent-core-v2): surface provider auth errors and align agent copy with v1 - #1631
Conversation
- map a 401 that survives forced token refresh to PROVIDER_AUTH_ERROR carrying the provider's sanitized message, instead of a misleading AUTH_LOGIN_REQUIRED re-login prompt - propagate provider auth errors through full compaction instead of wrapping them as compaction failure - export sanitizeStatusErrorMessage for reuse
…th v1 - rewrite repeated tool call reminders to redirect instead of prohibit (port of v1 MoonshotAI#1518) - simplify makeReminderText2 to (repeatCount), no longer echoing tool name and args - treat dismissed AskUserQuestion as no answer, not the recommended pick (port of v1 MoonshotAI#1550) - update toolDedupe test assertions and regenerate affected wire snapshots
🦋 Changeset detectedLatest commit: 1111f65 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 |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9e527fa73
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| function toLoginRequiredError(error: APIStatusError): Error2 { | ||
| /** |
There was a problem hiding this comment.
Move helper rationale to the file header
For files under packages/agent-core-v2, packages/agent-core-v2/AGENTS.md requires comments to live only in the top-of-file header and “never beside functions.” This newly added helper block comment sits next to toProviderAuthError, so it violates the local convention; please move the rationale into the file header or make the helper/test names carry it.
Useful? React with 👍 / 👎.
…e instance file - count writes that passed the released check and await them in release() so their atomic rename cannot recreate the file after unlink - harden the heartbeat test: 1ms cadence plus a post-release re-check catches the recreate-after-unlink race (verified failing on old code)
…eader Address Codex review: agent-core-v2 keeps comments in the top-of-file header only, never beside functions
Related Issue
No linked issue — the problems are explained below.
Problem
Three independent issues, two in
agent-core-v2(the DI × Scope engine) and one inkap-server:AUTH_LOGIN_REQUIREDwith a "send /login" prompt, sending users into a re-login loop that cannot fix the problem. The provider's actual rejection message was discarded, and full compaction wrapped the error as a genericCOMPACTION_FAILED, hiding it further.AskUserQuestionwas documented as answering with the recommended option, while v1 (fix(agent-core): treat dismissed AskUserQuestion as no answer, not recommended pick #1550) treats dismissal as "no answer".kap-server's instance registry had a shutdown race: a heartbeat write already in flight whenrelease()ran could complete its atomic rename after the unlink, recreating the just-removed instance file. This also madeinstanceRegistry.test.tsflaky in CI.What changed
1. Surface provider rejection on post-refresh 401
PROVIDER_AUTH_ERRORcarrying the provider's sanitized message, instead of a misleadingAUTH_LOGIN_REQUIREDre-login prompt (modelImpl.ts).COMPACTION_FAILED(fullCompactionService.ts).sanitizeStatusErrorMessagefor reuse (errors.ts).2. Align repeat-reminder and AskUserQuestion copy with v1
makeReminderText2to take only(repeatCount), no longer echoing tool name and arguments.AskUserQuestionas "chose not to answer" rather than selecting the recommended option (port of v1 fix(agent-core): treat dismissed AskUserQuestion as no answer, not recommended pick #1550).toolDedupetest assertions and regenerate affected wire snapshots.3. Drain in-flight heartbeat writes before unlinking the instance file
releasedcheck and haverelease()await them before unlinking, so an atomic rename can no longer recreate the file after removal (instanceRegistry.ts).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.