Skip to content

feat: make idle provider session retention configurable - #5858

Merged
ymichael merged 3 commits into
get-bb:mainfrom
toolittlecakes:fix/configurable-idle-session-timeout
Oct 20, 2026
Merged

ymichael merged 3 commits into
get-bb:mainfrom
toolittlecakes:fix/configurable-idle-session-timeout

Conversation

@toolittlecakes

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

The host daemon hard-coded a 30-minute idle-session timeout. On memory-constrained hosts, completed provider processes could remain resident even when active-thread concurrency was limited. Manually checking status and calling thread stop is not an atomic idle-only replacement for the guarded reaper.

What changed

  • Add the server-wide idleProviderSessionTimeoutMinutes General setting, defaulting to 30. It accepts nonnegative whole minutes; 0 makes eligible sessions releasable on the next sweep, and null disables automatic release.
  • Expose it in Settings → General, Settings search, the existing bb settings general command and SDK general-settings API. Preserve the stored value when older clients omit the field.
  • Send the policy when a daemon session opens and when a daemon connects or general settings change. Reuse the existing five-minute, non-overlapping reaper and all runtime eligibility/exclusivity guards. Saved session identity/history and manual stop behavior are unchanged.
  • Bump HOST_DAEMON_PROTOCOL_VERSION from 244 to 245 for the required session-response field and new policy-update message. Document the setting in configuration docs and bb guide customization.

Scope is deliberately global, with the existing sweep interval. This is an idle-retention control, not a loaded-process or memory cap; release may occur up to five minutes after the configured idle time.

How you verified

331 tests passed across targeted domain, protocol, daemon, runtime lifecycle, server API, CLI, UI, settings search and DB migration suites. Coverage includes live timeout changes, zero/never, reconnect, persisted readback, older-client preservation, invalid input, and existing guards against releasing active, pending, background or non-restorable sessions.

pnpm exec turbo run typecheck --filter=@bb/server --filter=@bb/host-daemon --filter=@bb/app --filter=@bb/cli --filter=@bb/domain --filter=@bb/host-daemon-contract
pnpm exec turbo run test --continue --filter=@bb/domain --filter=@bb/host-daemon-contract --filter=@bb/host-daemon --filter=@bb/server --filter=@bb/cli --filter=@bb/app --filter=@bb/agent-runtime -- app-settings.test.ts contract.test.ts src/app.test.ts server-client.test.ts server-connection.test.ts runtime-manager.test.ts general-settings.test.ts internal-session-protocol-version.test.ts command-output/settings.test.ts SettingsView.branch-prefix.test.tsx runtime.process-lifecycle.test.ts
pnpm exec turbo run test --filter=@bb/db -- migrate.test.ts
pnpm exec turbo run test --filter=@bb/app -- settings-search.test.ts

On an isolated local dev instance, selected five minutes in the browser, confirmed it through the API, reloaded and confirmed the persisted UI value; selected Never and verified null; then set a custom value of 17 through the source CLI and observed the open UI update live. Typecheck and formatting checks pass. No production instance was changed.

Fixes #3063

@github-actions

Copy link
Copy Markdown
Contributor

Thanks @toolittlecakes for the PR. This repo approves new contributors before it reviews their PRs, so this PR now closes on its own. That is expected. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to this PR, and explain what it changes and why. A maintainer then adds you to the allow list and can reopen the PR.

@github-actions github-actions Bot closed this Oct 20, 2026
@ymichael

Copy link
Copy Markdown
Collaborator

/approve @toolittlecakes

@github-actions

Copy link
Copy Markdown
Contributor

Approved @toolittlecakes for PRs. The name now stays on the allow list. The author can open a PR now.

@ymichael ymichael reopened this Oct 20, 2026
@ymichael
ymichael force-pushed the fix/configurable-idle-session-timeout branch from b0c3639 to aa4f91e Compare October 20, 2026 21:59
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.

Make idle provider-session reaping timeout configurable

2 participants