Skip to content

Make threads.stop release idle agent runtimes and document hidden worker cleanup #1573

Closed

Description

@SawyerHood

Plugins can spawn many hidden worker threads through bb.sdk.threads.spawn, but threads.stop currently does nothing for an idle thread.

Current behavior:

  • threads.stop releases active work, but the server does not dispatch it for an idle thread.
  • threads.archive eventually releases the process, but the release can take several minutes.
  • Repeated hidden-thread runs can retain many agent processes in one reused environment and exhaust host memory.
  • A requested turn can remain active when turn/started never arrives.

Extend the existing stop contract instead of adding a separate eviction concept.

Proposed product contract:

  • Make threads.stop(threadId) release active, starting, idle, error, archived, and stuck runtimes.
  • Make stop idempotent when no runtime is loaded.
  • Preserve the thread, events, environment, and future resume behavior.
  • Return only after the host completes the runtime release.
  • Keep archive as a separate organization and retention action.
  • Tell plugins to archive a finished hidden worker when appropriate, then call stop in a finally block.
  • Keep the existing bb thread stop <thread-id> CLI surface and update its help.
  • Update the daemon protocol version because stop changes its host-wire meaning.

Acceptance criteria:

  1. A plugin can promptly release an idle hidden thread agent process.
  2. The same call can reclaim active, starting, and stuck runtimes.
  3. A later turn can resume the preserved thread.
  4. Repeated stop calls succeed.
  5. The SDK, CLI guide, plugin API guide, and skills describe the same contract.
  6. Hidden-thread examples use cleanup in a finally block.

AGENT GENERATED: by GPT-5

Activity

  1. self-assigned this
    on Aug 14, 2026
  2. changed the title [-]Add explicit thread eviction APIs for plugin-managed hidden threads[/-] [+]Make threads.stop release idle agent runtimes and document hidden worker cleanup[/+] on Aug 14, 2026
  3. added a commit that references this issue on Aug 14, 2026
    1c3f3ef
  4. added a commit that references this issue on Aug 22, 2026
    995c1ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions