Skip to content

Apply a changed skill catalog to running Codex sessions instead of replacing the runtime - #8093

Merged
ymichael merged 1 commit into
mainfrom
bb/6301-changing-a-plugin-s-skills-replaces-every-i-thr_6ptp6zsyi8
Nov 24, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/6301-changing-a-plugin-s-skills-replaces-every-i-thr_6ptp6zsyi8

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

When the injected skill catalog changed (a plugin that contributes skills was installed, updated or edited), RuntimeManager.ensureCompatibleEntry in the host daemon compared the environment's skillCatalogHash at the next command and, if bb tracked no work in that environment (no live turn, open background task, terminal or in-flight command), called replaceEntryForSkillCatalog, which shut down the environment's whole runtime. For Codex that stops every bridge and app-server in the environment, and with them the background terminals the agent started (#6301). bb does not track those terminals as work, so a thread sitting between turns with a running command was always replaced. The replacement wasn't needed for Codex: its bridge already forwards a repeated skills/configure to every open app-server (skills/extraRoots/set). But the runtime only ever sent skills/configure once per bridge process, and process keys include the catalog hash, so the daemon had no way to apply a change in place.

What changed

  • Handshake: new optional skills.reconfigure (packages/provider-bridge-protocol/src/handshake.ts). It declares that a repeated skills/configure applies the new roots to open sessions from their next turn. It is optional so that existing third-party bridges that type InitializeResult with skills: { configure: true } still compile. Absent means "applies only to sessions started later".
  • Agent runtime: new AgentRuntime.reconfigureSkillRoots({ skillRoots }). It sends skills/configure to every running bridge that declared reconfigure (new skills/reconfigure adapter command, gated on the handshake). It then re-keys those processes and their threads' runtime configs to the new catalog key, so new sessions reuse the same bridge, and updates the runtime's default roots. It returns appliedToEveryProvider. The process-key derivation moved to providerProcessKey in bridge-launch-process-key.ts so the process manager can compute the new key.
  • Host daemon: ensureCompatibleEntry calls reconfigureSkillRoots first when the catalog differs. When every running bridge applied it, the entry keeps its runtime and swaps skillCatalogHash/skillRoots in place. It retains the previous catalog's staged directory (a turn in flight may still read it) and prunes older ones. Otherwise the previous behavior is unchanged: replace when idle, keep the old catalog when busy.
  • Codex bridge: declares skills: { configure: true, reconfigure: true }. Claude Code, Pi and ACP bridges apply roots only at session construction, so they don't declare it and keep the old behavior.
  • Docs: docs/provider-bridge-protocol.md (Injected skills) and the handshake block in docs/provider-plugin-api.md.
  • Plugin SDK 0.6.197 → 0.6.199, because the re-exported handshake schema changed. No server/daemon wire change, so no HOST_DAEMON_PROTOCOL_VERSION bump.

This follows option 1 of the issue (apply new skill roots to the running app-server). It does not use thread/backgroundTerminals/list, so nothing here depends on Codex ≥ 0.140; skills/extraRoots/set is already sent at app-server startup for every supported Codex version.

Other configuration-driven restarts with the same flaw (not changed here)

These still restart sessions while ignoring untracked running work, mainly Codex background terminals and in-flight plugin tool calls, which entryHasActiveRuntimeWork doesn't count:

  1. Shell environment change: RuntimeManager.replaceBaseShellEnv → evictIdleRuntimeEntries, and the shellEnvGeneration branch of ensureCompatibleEntry, shut down whole runtimes that have no tracked work.
  2. Idle provider session reaper: AgentRuntime.reapIdleProviderSessions (driven from apps/host-daemon/src/app.ts) stops an idle Codex session. It checks only bb-tracked background tasks.
  3. Codex bridge session rebuilds (plugins/provider-codex/src/bridge/bridge.ts, turn preparation): construction-signature changes ("Execution settings changed"), CODEX_HOME changes, removed writable folders (fork), and rebuildBeforeNextTurnReason after auth/rate-limit errors. Each replaces the thread's app-server.
  4. Mixed environments: if any running bridge in the environment can't reconfigure skills (Claude Code, Pi, ACP), the fallback still replaces the whole runtime, Codex sessions included.

A class-wide fix needs bridges to report running work, for example the Codex bridge answering from thread/backgroundTerminals/list on Codex ≥ 0.140 and reporting "unknown" (treated as busy) on older versions. These paths would then wait for that work to finish.

How you verified

Live repro with real Codex (codex-cli 0.171.0, gpt-6.2-astra) on a pnpm start:worktree dev instance, using a skill-only path plugin:

  • Before (origin/main 48f57bc): turn 1 started sleep 6302 as a Codex background terminal (pid 35192, child of app-server 33007). I ran bb plugin install on the skill plugin, then sent the next turn. The app-server was replaced (new pid 48109) and the sleep was gone. Agent: "No. ps showed no sleep 6302 process. I have the qa-alpha skill…"
  • After (this branch): sleep 7303 ran under app-server 80754. I added a qa-beta skill to the plugin and ran bb plugin reload; the catalog changed from 6fd272e7… to dbbd3907…. On the next turn the app-server was still 80754, the sleep was still pid 88226, and the agent read …/global-skills/dbbd3907…/skills/qa-beta/SKILL.md directly (the path came from Codex's skill catalog). Agent: "ps confirmed that sleep 7303 is still running with PID 88226. The qa-beta skill is available, and its codeword is HERON." I repeated the run on the final commit with sleep 7304 and a new qa-gamma skill: same app-server, the sleep survived, the skill was visible, and the staged catalogs were pruned to the previous and current ones.

Tests:

  • apps/host-daemon/src/runtime-manager.test.ts: new test that a changed catalog on an idle runtime whose providers apply it live keeps the same entry and runtime (no shutdown), swaps the catalog, and prunes older staged catalogs. It fails without the applySkillCatalogInPlace call (checked by removing it). The existing replacement/retention tests cover the fallback (fakes report appliedToEveryProvider: false).
  • packages/agent-runtime/src/runtime.skill-roots-capability.test.ts: against the scripted echo bridge (new reconfiguresSkills option), a bridge that declares reconfigure receives the second skills/configure, and a new session reuses the same bridge process. A bridge that doesn't declare it gets no second request, reports appliedToEveryProvider: false, and its session keeps working.
  • plugins/provider-codex/src/bridge/bridge.skills.test.ts: the Codex bridge advertises reconfigure and forwards a repeated skills/configure to the open session's app-server as skills/extraRoots/set, without relaunching it.
  • pnpm exec turbo run test typecheck lint --filter=@bb/agent-runtime --filter=@bb/host-daemon --filter=@bb/provider-bridge-protocol --filter=bb-plugin-provider-codex --filter=@get-bb/plugin-sdk: 21/21 tasks passed.

Fixes #6301

🤖 Generated with Claude Code

AGENT GENERATED

@ymichael
ymichael force-pushed the bb/6301-changing-a-plugin-s-skills-replaces-every-i-thr_6ptp6zsyi8 branch from 968633f to 9715a71 Compare November 24, 2026 22:26
…placing the runtime

A skill catalog change made the host daemon shut down an environment's whole
runtime at the next turn whenever bb tracked no work there. That killed every
Codex app-server in the environment and the background terminals its agent
had started, which bb does not track.

The runtime now offers the new skill roots to its running bridges first. A
bridge whose handshake declares skills.reconfigure applies a repeated
skills/configure to its open sessions; the runtime then re-keys that bridge
process to the new catalog. When every running bridge applies it, the daemon
keeps the runtime and swaps the entry's catalog in place. Bridges that cannot
reconfigure keep the previous behavior. The Codex bridge already forwarded a
repeated skills/configure to every open app-server, so it now declares the
capability.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael force-pushed the bb/6301-changing-a-plugin-s-skills-replaces-every-i-thr_6ptp6zsyi8 branch from 9715a71 to c76cd1c Compare November 24, 2026 22:36
@ymichael
ymichael merged commit e95021e into main Nov 24, 2026
52 checks passed
@ymichael
ymichael deleted the bb/6301-changing-a-plugin-s-skills-replaces-every-i-thr_6ptp6zsyi8 branch November 24, 2026 23:15
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.

Changing a plugin's skills replaces every idle Codex thread's runtime at its next turn and kills the thread's background commands

1 participant