Skip to content

Claude Code provider: sdk/system background_tasks_changed falls into assertNever and surfaces as provider/unhandled debug rows #2224

Closed

Description

@dhiyaancnirmal

Version

bb 0.39.0 (macOS host), Claude Code provider plugin

Summary

Claude Code sessions emit system messages of subtype background_tasks_changed
whenever the set of backgrounded tasks changes. bb does not have a case for it
in its sdk/system subtype classification, so it falls into the
assertNever default branch and surfaces as raw provider/unhandled debug
rows in the thread log.

Evidence

Real sessions show repeated rows like:

{"type": "provider/unhandled", "rawType": "sdk/system", "subtype": "background_tasks_changed", ...}

In the installed 0.39.0 bundle, the classifier handles these sdk/system
subtypes explicitly: compact_boundary, status, model_fallback*,
task_started, task_progress, task_updated, task_notification,
permission_denied, plus a long noise list (init, commands_changed,
hook_*, ...). background_tasks_changed is absent from both lists, so the
default branch throws:

Unhandled Claude visibility value: background_tasks_changed

and the event is emitted as provider/unhandled.

Impact

  • Log noise on every background-task change (observed multiple times per session).
  • Any future unmapped SDK subtype takes the same throwing path.

Suggested fix

Classify background_tasks_changed as noise (it duplicates information already
available through the backgroundTask item events driven by
task_started/task_updated), or fold it into the same normalized mapping as
the other task types.

Activity

  1. added theissue type on Aug 23, 2026
  2. added
    providers
    provider-claude-code
    on Aug 23, 2026
  3. SawyerHood commented on Aug 24, 2026

    @SawyerHood
    Collaborator

    ---Auto-Generated---

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/2224.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): plugins/provider-claude-code/src/visibility.ts keeps a closed allow-list of sdk/system subtypes; the newer Claude CLI (2.1.241, newer than the 2.1.197 bundled with the pinned SDK 0.3.197) emits background_tasks_changed on every background-task start/settle, which the list collapses to coverage "unknown", so delta-translation's unhandledDeltas() emits an unhandled delta and the runtime persists a provider/unhandled row (two per task); nothing throws — the assertNever branch the issue blames is unreachable.
    • Proposed fix: Add "background_tasks_changed" to visibility.ts in three places: the ClaudeSystemSubtype union, the toClaudeSystemSubtype() switch, and the noise case group in describeParsedClaudeRawEvent (the task_started/task_updated/task_notification bookends already drive bb's backgroundTask items, so the CLI's level signal carries nothing bb needs). Verified: the 2-test repro passes, the existing visibility/delta-translation/task-translation suites (80 tests) pass, and the plugin typecheck passes with the 7-line diff in /tmp/bb-reports/issues/2224/repro/proposed-fix.diff. No HOST_DAEMON_PROTOCOL_VERSION …
    • Caveats: The issue's mechanism claim is wrong: toClaudeSystemSubtype maps unlisted subtypes to "unknown" and the "unknown" case is handled, so assertNever never throws; the symptom (provider/unhandled rows) comes from the coverage-"unknown" path. Reproduced live against the user's PATH claude 2.1.241 (the plugin prefers PATH over the SDK-bundled 2.1.197, which does not emit this subtype), so installs runni…

    The report is self-contained: copy-paste repro steps with the test or script inline, expected vs actual output, screenshots where the bug is visual, and code permalinks at the base commit. It was independently re-executed by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Code

  4. added
    confirmed-repro
    on Aug 24, 2026
  5. technicalpickles commented on Aug 25, 2026

    @technicalpickles
    Contributor

    Found this while working on #2315 (composer background-task rows not being clickable) and reproducing it against main @ 42d2c1bec. Same root cause, new downstream symptom -- adding it here rather than filing a duplicate.

    Observed

    Spawned a real claude-code thread and had it run a shell command in the background (sleep N && echo done, via run_in_background). Two things, both reproduced on separate threads (thr_ax6z35nytu, thr_tpkqaaetc6, thr_k4pbiuhgbw, thr_cpbprby2au):

    1. No workKind: "workflow" row ever appears in the main timeline for the backgrounded command, running or completed. GET /api/v1/threads/:id/timeline never returns a row with workKind: "workflow" for it -- only the composer's activeBackgroundCommands projection has it while running. Once the task finishes, activeBackgroundCommands correctly goes back to [], but the completion shows up in rows as a generic system operation:

      {
        "kind": "system",
        "systemKind": "operation",
        "operationKind": "provider-unhandled",
        "title": "Unhandled Claude Code event",
        "detail": "SDK System\nRaw event: sdk/system\nPayload:\n{... \"subtype\": \"background_tasks_changed\", \"tasks\": [] ...}"
      }

      not as an update to the row itself. This matches the payload shape already documented in this issue.

    2. The open browser session didn't pick up the completion live. With the task's row still showing "Running background command... 1m 7s" (ticking well past the actual ~20s the command ran), a direct GET on the timeline endpoint already returned activeBackgroundCommands: [] -- the server had the correct state. A full page reload immediately showed the correct (completed) state. So server state was right; the client's live-update channel just never told it to refetch.

    Why I think it's the same cause (not confirmed, just consistent)

    Both symptoms are consistent with background_tasks_changed being exactly the signal that's supposed to (a) drive the background task's terminal state into the normal row-projection pipeline (packages/thread-view/src/build-thread-timeline.ts's buildWorkflowWorkRow, exercised for the happy path in packages/thread-view/test/background-task-timeline.test.ts), and (b) trigger the client to refetch when a background task's state changes. Since it's swallowed into assertNever → provider/unhandled before reaching either, neither happens. I haven't traced the client-refetch path to confirm (b) is literally gated on the same classification, so treat that half as a hypothesis, not a finding.

    What I ruled out

    Not caused by the PR I was working on (#2402) -- that diff only touches apps/app/src/components/promptbox/banner/ThreadBackgroundCommandsCard.tsx, useScrollToSearchedMessage.ts, and a new timelineRowNavigation.ts; none of it touches provider event projection or the realtime subscription path.

    Practical impact for #2315

    This is also why I couldn't verify #2315's "scroll to the row in the main timeline" click path live for a claude-code background command specifically -- there's never a rendered row to scroll to for this provider/task-type combination, regardless of timing. That path is still covered at the unit level (same data-timeline-row-id selector production code uses), just not confirmed against a real claude-code session.

    AGENT GENERATED

  6. SawyerHood commented on Sep 9, 2026

    @SawyerHood
    Collaborator

    Closing as completed: #2893 added explicit classification for Claude's sdk/system subtype background_tasks_changed, and the change shipped in desktop-v0.42.1.

    Current main recognizes the subtype and marks it as normalized rather than sending it through the unknown/unhandled classification path described here.

    Verified against current source and the merged commit's inclusion in the release; no new live reproduction was performed for this closure.

    AGENT GENERATED

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-claude-codeproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions