Skip to content

fix(codex): expose advisor consult tool on session reuse - #559

Merged
astyfx merged 1 commit into
mainfrom
fix/advisor-bug-0918
Sep 18, 2026
Merged

astyfx merged 1 commit into
mainfrom
fix/advisor-bug-0918

Conversation

@astyfx

@astyfx astyfx commented Sep 18, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the Advisor review step where enabling Advisor showed the activation notice but stave_consult_advisor never appeared in the Codex tool list, so it could not be called. Restores the tool on session reuse while keeping the prompt-cache benefit of reusing the native Codex thread.

Changes

Fixes

  • codex: expose stave_consult_advisor when a Codex native thread is reused. A resumed thread kept its previous MCP tool catalog, so first-time Advisor activation only added the notice. The collaboration grant profile is now tracked with the resumed thread, and a fresh thread is forced only when that profile changes.

Refactors / Chores

  • codex: extract thread-session tracking into electron/providers/codex-thread-session.ts (profile-aware resume decision, remember/forget helpers).
  • advisor: validate the current turn ID on consult so a stale prior-turn or foreign-task key can no longer spend a new turn's Advisor grant; refuse a stable channel for turns with no task ID; protect against late cleanup revoking a new turn's grant.

Test Evidence

  • bun run typecheck — pass
  • bun run check:licenses — pass (420 production packages)
  • bun run check:max-lines-ratchet — pass (22 files)
  • bun test tests/codex-app-server-runtime.test.ts tests/provider-runtime-advisor.test.ts tests/advisor-stable-channel.test.ts tests/codex-thread-session.test.ts — 95 pass, 0 fail
  • Full bun test: 62 pre-existing failures unrelated to this change (executable resolution, Lens CDP, Kiro ACP, host-service timeouts). Verified against a clean origin/main baseline, which shows 63 equivalent failures with these changes stashed.

Behavioral cases now covered by tests: Advisor off → on reuses the session and reinstalls the tool catalog; turn-scoped consult requires the turn ID from the briefing; stale/foreign/no-task-ID keys are rejected; the consult channel is retained while the per-turn grant is revoked.

Notes

Not yet verified: real Desktop reproduction in a packaged build and prompt-cache hit-rate measurement. The pre-existing full-suite failures above are environment/timing sensitive and independent of this change.

Reusing a Codex native thread across turns kept the previous MCP tool
catalog, so enabling Advisor added the activation notice but never
surfaced stave_consult_advisor, leaving the tool uncallable.

Track the collaboration grant profile alongside the resumed thread and
force a fresh Codex thread only when that profile changes, so the tool
catalog and headers are reinstalled on first Advisor activation while
later off/on toggles keep reusing the session and its prompt cache.
Validate the current turn ID on consult so a stale prior-turn or
foreign-task key can no longer spend a new turn's Advisor grant, and
refuse a stable channel for turns that carry no task ID.
@astyfx
astyfx requested a review from a team as a code owner September 18, 2026 04:43
@astyfx
astyfx requested review from JongSikLim and heath-s and removed request for a team September 18, 2026 04:44
@upwind-code-us

upwind-code-us Bot commented Sep 18, 2026

Copy link
Copy Markdown

Upwind Upwind Code Scan - ✅ Passed

0 newly introduced vulnerabilities · 0 resolved · 57 total in this PR vs main

Total breakdown: 🔶 6 High | 🟡 48 Medium | 🟢 3 Low

View full analysis in Upwind Console

Scan completed in 6s

Scan history (1 scan)
Commit Scanned at New Resolved Net
b73d8c1 < 2026-09-18 04:44 UTC 0 0 0

Last scanned: b73d8c1 · 2026-09-18 04:44 UTC

@upwind-code-us

upwind-code-us Bot commented Sep 18, 2026

Copy link
Copy Markdown

Upwind Upwind IaC Scan - ✅ Passed

0 newly introduced misconfigurations · 0 resolved · 0 total in this PR vs main

View full analysis in Upwind Console →

Scan completed in 6s

Scan history (1 scan)
Commit Scanned at New Resolved Net
b73d8c1 < 2026-09-18 04:44 UTC 0 0 0

Last scanned: b73d8c1 · 2026-09-18 04:44 UTC

@astyfx
astyfx enabled auto-merge (squash) September 18, 2026 04:44

@heath-s heath-s left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@astyfx
astyfx merged commit d938f64 into main Sep 18, 2026
6 checks passed
@astyfx
astyfx deleted the fix/advisor-bug-0918 branch September 18, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants