Skip to content

No plugin-visible turn-completion hook, so provider session correlation cannot be durably recorded #2134

Description

@pixexid

Summary

A bb plugin cannot durably record which provider session produced a given turn, because there is no plugin-visible lifecycle event at turn completion. The information exists in the platform at that moment — threadEventSchema carries providerThreadId and providerCheckpointId — but no plugin hook fires while it is available.

Plugins that need to answer "which model actually executed this turn?" after the fact must instead reconstruct the answer later by deriving a provider session-log path from environment.path. That derivation fails permanently once the environment is removed, so the answer decays from knowable to unknowable purely as a function of environment lifetime.

What exists today

PluginEvents exposes:

thread.created
thread.active
thread.idle
thread.failed
thread.archived
thread.deleted

None of these is turn completion. thread.idle is the closest, but it is a thread-state transition rather than a per-turn boundary, and a thread can go idle without a turn having completed.

Reproduction

  1. In a plugin, attempt to record providerThreadId and providerCheckpointId for each completed turn of a thread. There is no event to attach that to.
  2. As the available workaround, derive the provider session log location from the thread's environment.path after the fact.
  3. Remove the environment.
  4. environment.path is now null. The provider session file still exists on disk, and its filename still contains the provider thread UUID, but nothing binds it to the BB thread. A correct implementation must return "unknown" rather than match on filename alone, since a filename match is not proof of association.

Observed scale

On one host: 907 threads enumerated, 879 retaining an environmentId, 797 unique environments queried. 716 environments returned path: null, and 763 threads sit on those. For those threads the association is unrecoverable — not degraded, gone.

What would resolve it

Either of:

  1. A turn-completion plugin hook, fired while providerThreadId and providerCheckpointId are in scope, so a plugin can persist the association itself.
  2. A BB-owned correlation record binding a thread (or turn) to its provider session identity, readable independently of whether the environment still exists.

Either removes the coupling between an audit-time question and environment retention. The first is smaller and puts the persistence choice in the plugin; the second means plugins do not each reimplement it.

Why a workaround is not adequate

A thread.idle observer could query events.list and read environment.path while it is still present, then persist the association itself. That works, but it reconstructs a fact the platform already had rather than recording one, and it races environment removal for threads that end near a cleanup. It also means every plugin with this need writes the same fragile derivation.

Note on the failure mode

This degrades safely — the affected read returns unknown, never a wrong answer. That is also why it went unnoticed for a long time: the only symptom is an honest "unknown" to a question that is typically asked long after the fact, during an audit or an incident reconstruction, which is exactly when the answer matters most.

Filed from the bb-collab project.

Activity

  1. added
    plugins
    threads
    on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pluginsthreads

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions