Repository navigation
Conversation
ymichael
added a commit
that referenced
this pull request
Sep 1, 2026
## Human comments ## What was wrong The Claude provider represented a bb thread attachment and its resident Claude SDK query as one `ThreadSession`. That forced an idle query and Claude child process to remain alive until core released the entire attachment after 30 minutes; closing the combined object earlier also removed routing state, so the next `turn/start` failed with `No active session`. ## What changed - Split retained thread attachment state from the optional resident `SdkSession` and query. - Add the Claude provider setting `idleQueryReleaseEnabled`, defaulted off for the bake period. Changes apply on the next start, resume, or turn command. - When enabled, release newly started, restored, forked, and post-turn queries after a provider-owned 30-second quiescent grace period while preserving the attachment and provider thread id. - Lazily construct one replacement query on the next normal turn, resume the same Claude conversation, and preserve `session/replaced` → identity → `session.reset` ordering. - Coalesce simultaneous wakes with an attachment-local promise and invalidate stale idle callbacks with a residency generation. - Treat open turns, pending Claude-native background tasks and monitors, pending interactions, and forwarded tool calls as non-quiescent. Monitor tasks remain invisible in the timeline while protecting resident work. - Keep dormant live settings and permission grants available for reconstruction; `thread/stop` still deletes the attachment, allowing core's existing 30-minute cleanup to retire the bridge worker. - Reject invalid `thread/resume` requests before constructing a query. - Document the provider setting in the guide, configuration reference, and shipped bb CLI skill. Enable the bake with: ```sh bb plugin config provider-claude-code set idleQueryReleaseEnabled true ``` This is Claude-provider policy only. The option travels in the existing opaque provider-options bag and old host daemons already forward that bag, so the server/daemon wire contract and `HOST_DAEMON_PROTOCOL_VERSION` are unchanged. Immediate auth-failure eviction and credential-store startup serialization remain separate follow-up PRs (#2804 and #2807). ## How you verified The fake-clock regressions fail before the implementation and cover: - release remaining disabled by default; - a newly started or restored query receiving no turn; - post-turn idle release and lazy context-preserving wake; - disabling release on the next turn cancelling a scheduled eviction; - warm reuse inside the grace period; - provider-native background tasks and hidden monitor work blocking release; - monitor completion starting a fresh grace period; and - simultaneous turns creating exactly one replacement query. Commands run after rebasing onto current `origin/main`: - `CI=1 pnpm exec turbo run test typecheck --filter=bb-plugin-provider-claude-code --force` — 24 files, 349 tests passed; typecheck passed - `CI=1 pnpm exec turbo run test typecheck --filter=@bb/templates --force` — 43 tests passed; typecheck passed - `CI=1 pnpm exec turbo run test --filter=@bb/server --force -- test/skills/builtin-skills-copy.test.ts test/skills/shipped-skills-quality.test.ts` — 14 tests passed - `CI=1 pnpm exec turbo run test --filter=@bb/server --force -- test/threads/thread-runtime-config.test.ts` — 30 tests passed - `git diff --check origin/main...HEAD` Live dev CLI QA confirmed the setting schema reports `default: false`, setting it to `true` is reflected immediately, and unsetting it restores the effective value to `false`. > AGENT GENERATED
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.
Human comments
What was wrong
Separate bb Claude bridge workers could construct Agent SDK queries and run Claude's startup/auth initialization concurrently even when they resolved to the same credential store. Because Claude OAuth refresh credentials can rotate, that unnecessarily increases bb's exposure to the upstream concurrent-refresh race tracked in anthropics/claude-code#88583.
What changed
CLAUDE_CONFIG_DIR/default Claude config directory on Linux and Windows, or the macOS Claude Keychain scope.initializationResult()settles (or the query ends first), for both thread sessions and the bridge model-discovery probe.This serializes only bb-managed Claude startup/auth initialization among bridge workers sharing one host daemon's Claude-plugin data directory. It does not serialize ongoing work or later mid-session refreshes, standalone Claude CLI/Desktop processes, bridge workers belonging to another bb daemon data directory, explicit credential modes, or unrelated credential stores. It does not add general idle-session residency or auth-failure query eviction.
No host-daemon protocol or public plugin API changed, so
HOST_DAEMON_PROTOCOL_VERSIONis unchanged.How you verified
initializationResult().pnpm exec turbo run test --filter=bb-plugin-provider-claude-code --force— 24 files, 342 tests passed.pnpm exec turbo run typecheck --filter=bb-plugin-provider-claude-code --force— 4 tasks passed.bb plugin build plugins/provider-claude-code— passed.git diff --check origin/main...HEAD— passed.Related to anthropics/claude-code#88583.