Skip to content

fix(compact): resolve the session's agent; sweep deprecated CLI profiles from all agent stores#455

Merged
webdevtodayjason merged 1 commit into
devfrom
fix/livebox-compact-agent-resolution
Jun 12, 2026
Merged

fix(compact): resolve the session's agent; sweep deprecated CLI profiles from all agent stores#455
webdevtodayjason merged 1 commit into
devfrom
fix/livebox-compact-agent-resolution

Conversation

@webdevtodayjason

Copy link
Copy Markdown
Contributor

Live-box bug cluster — HANDOFF item 0 (Jason hit this 2026-06-12 ~12:50 on dev.2)

/compact resolved the wrong agent → "Compaction skipped: No API key"

Two call paths never threaded the session's agent dir into compactEmbeddedPiSession, so it fell back to resolveArgentAgentDir() = <state>/agents/main/agent — and Jason has a real agent literally named main whose store held only the deprecated openai-codex:codex-cli profile:

  • gateway commands.compact (the path webchat hits): used resolveDefaultAgentId (ignores the session key entirely) and passed no agentDir. Now resolves via resolveSessionAgentId({sessionKey}) and threads agentDir. This also fixes model resolution + workspace for non-default agents' sessions.
  • chat /compact handler: same missing agentDir; now passes resolveAgentDir(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; thinkLevel now goes through normalizeThinkLevel). known-failing baseline 191 → 189.

doctor only cleaned the default agent's deprecated CLI profiles

maybeRemoveDeprecatedCliAuthProfiles ran 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 (updateAuthProfileStoreWithLock grew a raw mode) so main-agent credentials are never copied into other agents' files. Detection reads the raw store file — deliberately avoiding ensureAuthProfileStore'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

  • 2 new gateway cases: agent:argent:main compacts with agents/argent/agent (not agents/main); a session of the agent actually named main still resolves to agents/main.
  • 1 new doctor case: sweep cleans the deprecated profile from agents/main/agent without smearing default-agent credentials into it; existing test gained ARGENT_STATE_DIR isolation (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 in auth-profiles.auth-profile-cooldowns.test.ts reproduces at clean HEAD (pre-existing suite baseline).

Not addressed here (tracked in HANDOFF item 0): operator-lane prompt diet (#407), stale contextTokens on the live session entry (likely self-heals on next successful turn via persistSessionUsageUpdate), split state dirs.

🤖 Generated with Claude Code

…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>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 176367f7-62c2-4df3-a341-090670c51939

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/livebox-compact-agent-resolution

Comment @coderabbitai help to get the list of available commands and usage tips.

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
webdevtodayjason merged commit 33acd59 into dev Jun 12, 2026
16 checks passed
@webdevtodayjason
webdevtodayjason deleted the fix/livebox-compact-agent-resolution branch June 12, 2026 19:58
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant