Skip to content

Claude context ring switches between the auto-compact window (256K) and model window (1M) during a turn #4441

Description

@werserk

Summary

With Claude Code's autoCompactWindow set to 256000, bb's context ring shows
256K after a turn, then 1M while the next turn runs, and returns to 256K after
that turn. The two denominators describe different things: the configured
auto-compact window and the model's context capacity. This makes the same ring
change scale during normal agent activity.

Reproduction

  1. Use bb 0.44.0 with the Claude Code provider and a Claude model whose
    modelUsage.contextWindow is 1M.
  2. Set Claude Code's autoCompactWindow to 256000.
  3. Complete a turn and observe the context ring at 256K.
  4. Start another turn and observe the ring while the agent is working. It
    changes to 1M, then returns to 256K after the post-turn context snapshot.

The event trace below came from bb thread log <thread-id> --all --json in
bb 0.44.0. The raw thread log is omitted because it contains conversation
content.

Sequence Event modelContextWindow snapshot.contextWindowTokens
16750 turn/completed — —
16751 thread/contextWindowUsage/updated 256000 256000
16752 turn/started — —
16756 thread/contextWindowUsage/updated 1000000 absent
16758 thread/contextWindowUsage/updated 1000000 absent

The same pattern repeats at seq 16861 (256000 with snapshot), 16867 and
16869 (1000000 without snapshot), and 16872 (256000 with snapshot).

Expected behavior

The native ring should keep the latest Claude auto-compact snapshot's
contextWindowTokens (256K here) as its denominator throughout subsequent
turns, while still updating the used-token estimate. A streamed model-capacity
value should not replace that display denominator while the auto-compact
window is active. The underlying 1M model capacity should remain available.

Code pointers

In the installed bb 0.44.0 bundle under node_modules/bb-app/:

  • server/dist/builtin-plugins/provider-claude-code/dist/host.js:208 calls
    session.getContextUsage() after a turn and publishes
    snapshot.contextWindowTokens as the context-window size.
  • The same host.js:196 extracts modelUsage.contextWindow from Claude SDK
    messages for the streamed context event.
  • server/dist/start-server.js:62035-62087 selects the latest usable context
    event, so the next streamed 1M event replaces the 256K snapshot in the
    indicator's input.

Related source at the bb 0.44.0 source baseline (0baa605b):
snapshot publication,
context normalization,
SDK extraction,
latest-event projection,
and ring rendering.

Could the indicator retain the most recent auto-compact snapshot window
through later estimated stream events? A regression case with the alternating
event order above would make the behavior testable.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions