fix(compact): resolve the session's agent; sweep deprecated CLI profiles from all agent stores#455
Merged
Conversation
…les from every agent store
Live-box bug cluster (HANDOFF item 0, hit by Jason 2026-06-12 ~12:50 on dev.2):
- gateway commands.compact resolved the DEFAULT agent and never passed
agentDir, so compaction fell back to <state>/agents/main/agent — the
agent literally named "main" — and found only its deprecated codex-cli
profile ("Compaction skipped: No API key"). Now resolves the session
key's agent (resolveSessionAgentId) and threads agentDir through.
Also fixes the two baseline tsc errors in the file (one-object call to
resolveAgentWorkspaceDir; unnormalized thinkLevel) — baseline 191→189.
- chat /compact had the same missing-agentDir fallback; now threads the
resolved session agent's dir into compactEmbeddedPiSession.
- doctor's deprecated CLI-profile cleanup only ran on the main/default
store, which is why main's stale codex-cli profile survived while
argent's was cleaned. It now sweeps every configured agent's store
(raw, unmerged reads/writes so main credentials never smear into other
agents' files; updateAuthProfileStoreWithLock grew a `raw` mode).
- context-overflow classification now logs the raw provider rejection
(chat replies replace it with generic overflow text, which made the
webchat gpt-5.5 "Context overflow at 77k/272k" undiagnosable). The
retry discriminator for that bug remains pending on the live box.
Tests: 2 new gateway compact agent-resolution cases, 1 new doctor sweep
case (+ state-dir isolation for the existing one); tsc-since clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
webdevtodayjason
added a commit
that referenced
this pull request
Jun 12, 2026
…xed in PR #455, discriminator capture landed Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
webdevtodayjason
added a commit
that referenced
this pull request
Jun 12, 2026
…sweep (#455) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
webdevtodayjason
added a commit
that referenced
this pull request
Jun 12, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Live-box bug cluster — HANDOFF item 0 (Jason hit this 2026-06-12 ~12:50 on dev.2)
/compactresolved the wrong agent → "Compaction skipped: No API key"Two call paths never threaded the session's agent dir into
compactEmbeddedPiSession, so it fell back toresolveArgentAgentDir()=<state>/agents/main/agent— and Jason has a real agent literally namedmainwhose store held only the deprecatedopenai-codex:codex-cliprofile:commands.compact(the path webchat hits): usedresolveDefaultAgentId(ignores the session key entirely) and passed noagentDir. Now resolves viaresolveSessionAgentId({sessionKey})and threadsagentDir. This also fixes model resolution + workspace for non-default agents' sessions./compacthandler: same missingagentDir; now passesresolveAgentDir(cfg, <session agent>).Bonus: the gateway file's two baseline tsc errors are fixed honestly (
resolveAgentWorkspaceDir({cfg, agentId})was a one-object call to a two-arg function — at runtime it silently resolved the default workspace for every agent;thinkLevelnow goes throughnormalizeThinkLevel). known-failing baseline 191 → 189.doctor only cleaned the default agent's deprecated CLI profiles
maybeRemoveDeprecatedCliAuthProfilesran on the main store only — which is why argent's codex-cli profile was cleaned while main's survived. It now sweeps every configured agent's store (deduped by path), lists affected store files in the doctor note, and updates per-agent stores unmerged (updateAuthProfileStoreWithLockgrew arawmode) so main-agent credentials are never copied into other agents' files. Detection reads the raw store file — deliberately avoidingensureAuthProfileStore's main-merge (false positives) and external-CLI re-sync (import-then-delete churn)."Context overflow" misclassification — capture side landed
The webchat gpt-5.5 failure (~77k input vs 272k window, zero model activity) was undiagnosable because the chat reply replaces the raw provider rejection with generic overflow text and nothing logged it. Both classification points (prompt-error and assistant-error paths) now log the raw rejection (truncated to 600 chars). The retry discriminator on the live box is still pending — next occurrence will self-document in gateway logs.
Tests / verification
agent:argent:maincompacts withagents/argent/agent(notagents/main); a session of the agent actually namedmainstill resolves toagents/main.agents/main/agentwithout smearing default-agent credentials into it; existing test gainedARGENT_STATE_DIRisolation (the sweep walks the state dir — tests must never touch the real one).tsc-since: no net-new errors (189 baseline). Targeted suites green; the one failure inauth-profiles.auth-profile-cooldowns.test.tsreproduces at clean HEAD (pre-existing suite baseline).Not addressed here (tracked in HANDOFF item 0): operator-lane prompt diet (#407), stale
contextTokenson the live session entry (likely self-heals on next successful turn viapersistSessionUsageUpdate), split state dirs.🤖 Generated with Claude Code