Skip to content

provider-pi stores every pi system message twice, in full, as provider/unhandled (0.66 GB on one install) #7522

Closed

Description

@pascal-de-ladurantaye

Summary

Pi emits a role: "system" message (its prompt sections and tool declarations) when a session starts and again whenever sections or tools change, each time as a message_start and a message_end event. provider-pi doesn't recognize the system role, so both events fall through to provider/unhandled with the whole raw payload. That gives two identical copies of a 10–130 KB prompt snapshot that nothing reads. I expected bb to treat a pi system message as known, either dropping it or storing it once.

This issue covers only that subtype: rawType sdk/message_start or sdk/message_end with rawEvent.params.message.message.role = "system". Other provider/unhandled rows (unscoped thinking, tool calls, model fallbacks, legacy image results) are used elsewhere and are not part of this issue.

Versions and environment

  • bb 0.49.0 (desktop app), macOS 27.2 arm64
  • provider pi, pi CLI 1.5.0
  • local data dir ~/.bb, no remote machine

Steps to reproduce

  1. bb thread spawn --project <project> --provider pi --prompt "Reply only with ok."
  2. bb thread wait <thread>
  3. bb thread log <thread> --json --limit 20 | jq -c '.[]
      | select(.type=="provider/unhandled")
      | {seq, rawType: .data.rawType,
         role: .data.rawEvent.params.message.message.role,
         chars: (.data|tostring|length)}'

I reproduced this in a new thread on 0.49.0, not on a clean data dir. The size depends on the skills, plugins and tools installed, so expect a smaller number on a fresh install. There are still two rows.

Expected vs actual

{"seq":9,"rawType":"sdk/message_start","role":"system","chars":123522}
{"seq":10,"rawType":"sdk/message_end","role":"system","chars":123518}

Expected: no provider/unhandled row for a pi system message, or at most one compact row. Actual: two adjacent rows whose rawEvent.params.message.message is byte-for-byte the same. A trimmed, made-up example:

{"providerId":"pi","rawType":"sdk/message_start","rawEvent":{"jsonrpc":"2.0","method":"sdk/message",
 "params":{"message":{"type":"message_start","message":{"role":"system","content":"",
 "sections":{"tools":"…","skills":"…"},"toolsAdded":[{"name":"read","description":"…","parameters":{}}],
 "timestamp":0}}}}}

Evidence

Size, measured on one install (37 days, about 2,900 threads, all pi). I took a consistent copy of ~/.bb/bb.db with SQLite .backup and measured it with dbstat. Event content is sum(length(data)) grouped by event type, and for this subtype by rawType and message role.

  • Pi system-message snapshots: 13,107 rows, 0.66 GB, about 50 KB per row. Of that, prompt sections for skills are 0.28 GB, tool schemas 0.23 GB, and other appended sections 0.10 GB. Half of it is the second copy.
  • For scale, provider/unhandled as a whole is 67,655 rows and 0.75 GB. This issue is about the 0.66 GB subtype only. The events table is 4.21 GB of a 5.35 GB file.
  • In one long thread there were 235 system messages over 969 turns, 40 of them ≥ 40 KB. All 235 message_start/message_end pairs were adjacent and identical. I checked this with read-only indexed queries on one thread.
  • No pruning policy covers these rows (docs/events-table-pruning.md: "No other event types are deleted"), so they stay for the life of the thread.

Code (the same at desktop-v0.49.0 and at current main; neither file changed between them):

  • toPiMessageBoundaryRole maps only assistant, custom, toolResult and user. system becomes unknown: tag, main.
  • A message boundary with an unknown role gets coverage unknown, not noise: tag, main.
  • translate returns nothing for the boundary (neither the assistant nor the custom schema matches), so the envelope goes to unhandledDeltas with the full raw event: tag, main. For unhandledDeltas itself: tag, main.
  • Pi documents this message type as SystemMessage (role: "system", sections, toolsAdded, toolsRemoved) in its docs/message-types.md.

Suggested fix: recognize system as a message-boundary role and classify it as noise. If bb wants a record of prompt changes, keep one compact row from message_end, with section names, sizes and tool names. The fix should be specific to this role, because other provider/unhandled rows are read (for example model-fallback rows in packages/db/src/data/events.ts).

What you ruled out

Suggested priority and effort (optional)

Medium: it hits every pi thread and grows with prompt size and session restarts. No data is lost, and there is no user workaround short of deleting threads. Effort is probably Low.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report. (It ends with the marker. The investigation report is a private local analysis, summarized above.)

AGENT GENERATED

Activity

  1. added theissue type on Nov 13, 2026
  2. added
    providers
    provider-pi
    confirmed-repro
    on Nov 13, 2026
  3. bb-slop-cop commented on Nov 13, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low. Applied providers, provider-pi, and confirmed-repro.
    • Reproduction report: REPRODUCED · high root-cause confidence.
    • Root cause: System-role boundaries are classified as unknown, so both start/end envelopes retain the full prompt snapshot as provider/unhandled events.
    • Verification: The focused translator/assembler regression fails in two clean trusted-main checkouts and passes after the fix. All 353 Pi tests pass (6 skipped), along with lint and typecheck. The reported installation's disk totals were not independently verified.
    • Fix: PR #7525, ready for review, not merged. Two files, 43 changed text lines; preserves unknown-role diagnostics and leaves historical data unchanged.
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

    confirmed-reproprovider-piproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions