← reports

#5273 · Composer service tier crosses provider selections

BugPriority: MediumEffort: Mediumproviders · ui · provider-codex · provider-claude-codeGitHub issue2026-10-09

Trusted base: 8395b050a14d7207cef9aee914af6a60cd8f5ba4 (fetched canonical main).

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

Choosing Fast for Codex in a new-thread composer leaves that choice active when the same composer switches to Claude Code. The actual composer hook returns Claude Code with serviceTier: "fast" and marks that tier as an explicit input, despite no Claude-specific Fast selection. Tier preferences are tab-scoped but not provider-scoped; provider switching remembers model and reasoning, not service tier. Both providers advertise the same Fast identifier, so capability reconciliation accepts the carried-over value. This is a verified composer-state defect, not a claim that a live paid Claude turn or its bill was measured.

2. Claims vs findings

ClaimFindingEvidence
A Codex Fast selection carries into Claude Code.Verified by executionThe real new-thread hook returns Claude Code / Fast in two clean base checkouts; the regression assertion expecting Default fails.
Fast eligibility can only be enabled globally.Verified staticallyThe app settings contract has one boolean; the Providers settings control describes all new turns, and the server resolver uses the same boolean.
A Claude turn is requested and recorded as Fast, including project defaults.Static path supported; live record unverifiedThe composer submits its returned tier; server resolution accepts an explicit provider-supported tier; persistence upserts one row per project. No live turn or event/database snapshot was created.
Claude Fast uses the subscription faster.Unverified billing effectThe provider describes higher cost per token and the bridge maps Fast to fastMode. Actual usage and billing were not measured.
A machine environment override forces standard speed despite recorded Fast.UnverifiedNo provider process or environment override was executed. This workaround is not needed to demonstrate the composer defect.
Related project defaults are keyed by project, not provider.Verified staticallyThe database unique index and conflict target contain projectId only.

3. Environment

4. Minimal reproduction

This is a nonvisual state/dispatch-input reproduction. It does not require browser automation or screenshots. Use the source below; the expected failed assertion is the evidence of the bug.

  1. Obtain the trusted source and build its normal dependencies:
    git clone https://github.com/get-bb/bb.git bb-5273-repro
    cd bb-5273-repro
    git checkout --detach 8395b050a14d7207cef9aee914af6a60cd8f5ba4
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build
  2. Create the focused reproduction test from this complete block:
    cat > apps/app/src/hooks/issue-5273-repro.test.tsx <<'REPRO'
    // @vitest-environment jsdom
    
    import { act, cleanup, renderHook, waitFor } from "@testing-library/react";
    import type { SystemExecutionOptionsResponse } from "@bb/server-contract";
    import { makeProviderInfo } from "@bb/test-helpers/domain-fixtures";
    import { afterEach, expect, it, vi } from "vitest";
    import { sdk } from "@/lib/sdk";
    import { createQueryClientTestHarness } from "@/test/queryClientTestHarness";
    import { systemConfigQueryKey } from "./queries/query-keys";
    import { useThreadCreationOptions } from "./useThreadCreationOptions";
    
    vi.mock("@/lib/sdk", () => ({
      sdk: {
        system: {
          executionOptions: vi.fn(),
          providerStates: vi.fn(),
        },
      },
    }));
    
    afterEach(() => {
      cleanup();
      window.localStorage.clear();
      window.sessionStorage.clear();
      vi.clearAllMocks();
    });
    
    it("does not transfer an explicit Fast choice to another provider", async () => {
      window.localStorage.clear();
      window.sessionStorage.clear();
      const providers = ["codex", "claude-code"].map((providerId) =>
        makeProviderInfo({
          id: providerId,
          capabilities: { supportsServiceTier: true },
        }),
      );
      vi.mocked(sdk.system.executionOptions).mockImplementation(async (args) => {
        const providerId = args?.providerId ?? "codex";
        const model = providerId === "codex" ? "gpt-5.4" : "claude-opus-4-5";
        const response: SystemExecutionOptionsResponse = {
          providers,
          models: [
            {
              id: model,
              model,
              displayName: `${providerId} model`,
              description: "",
              supportedReasoningEfforts: [
                { reasoningEffort: "medium", description: "" },
              ],
              defaultReasoningEffort: "medium",
              isDefault: true,
            },
          ],
          selectedOnlyModels: [],
          permissionCeiling: "full",
          modelLoadError: null,
        };
        return response;
      });
      vi.mocked(sdk.system.providerStates).mockResolvedValue({ providers: [] });
      const { wrapper, queryClient } = createQueryClientTestHarness();
      queryClient.setQueryData(systemConfigQueryKey(), {
        generalSettings: { allowFastServiceTier: true },
      });
      const { result } = renderHook(
        () =>
          useThreadCreationOptions({
            scope: "new-thread",
            initialProviderId: "codex",
            initialServiceTier: "default",
          }),
        { wrapper },
      );
      await waitFor(() => {
        expect(result.current.selectedProviderId).toBe("codex");
        expect(result.current.supportsServiceTier).toBe(true);
        expect(result.current.selectedModel).toBe("gpt-5.4");
      });
      act(() => result.current.setServiceTier("fast"));
      expect(result.current.serviceTier).toBe("fast");
      act(() => {
        result.current.setProviderModelReasoning({
          providerId: "claude-code",
          model: "claude-opus-4-5",
          reasoningLevel: "medium",
        });
      });
      await waitFor(() => {
        expect(result.current.selectedProviderId).toBe("claude-code");
        expect(result.current.selectedModel).toBe("claude-opus-4-5");
        expect(result.current.supportsServiceTier).toBe(true);
      });
      console.log(
        JSON.stringify({
          providerId: result.current.selectedProviderId,
          serviceTier: result.current.serviceTier,
          executionInputSources: result.current.executionInputSources,
        }),
      );
      expect(result.current.serviceTier).toBe("default");
    });
    REPRO
  3. Run only that test through Turbo:
    pnpm exec turbo run test --filter=@bb/app -- src/hooks/issue-5273-repro.test.tsx

Expected: after choosing Fast for Codex and switching to Claude Code, the destination should use its untouched Default tier. Actual: Claude Code inherits Fast, classified as explicit.

{"providerId":"claude-code","serviceTier":"fast","executionInputSources":{"providerId":"explicit","model":"explicit","serviceTier":"explicit","reasoningLevel":"explicit"}}
AssertionError: expected 'fast' to be 'default' // Object.is equality
Expected: "default"
Received: "fast"

Both runs exited 1 with one test failing at the final service-tier assertion. All prerequisite assertions (provider switch, destination model, service-tier support, and initial explicit Fast choice) passed.

5. Root cause

  1. One serviceTierAtom for all providers and its parameterless preference hook contrast with provider-keyed model/reasoning atom families. The tier storage key has no provider component.
    const serviceTierAtom = atomWithStorage<StoredServiceTier>(
      SERVICE_TIER_STORAGE_KEY,
      "",
      createTabScopedStorage<StoredServiceTier>(...),
      { getOnInit: true },
    );
  2. rawServiceTier resolves the single stored value regardless of which provider is selected. setProviderModelReasoning switches provider/model/reasoning without clearing or replacing that tier.
  3. Tier reconciliation checks destination support and reconcileServiceTier retains any advertised matching identifier preserve Fast when the destination also advertises Fast. Claude Code declares Fast.
  4. Submission includes the selected service tier and source classification turns that leaked selection into an explicit request. Server tier resolution uses one global eligibility gate; it does not know which provider the user's earlier toggle targeted.
    const serviceTier = getAppSettings(deps.db).allowFastServiceTier
      ? resolveProviderServiceTier(deps.providerRegistry, {
          providerId: thread.providerId,
          requested: args.input.serviceTier,
          inherited: lastExecution?.serviceTier ?? projectExecution?.serviceTier,
        })
      : DEFAULT_SERVICE_TIER;
  5. The Claude bridge maps Fast to SDK settings faithfully translates the request:
    fastMode: params.serviceTier === "fast"
    This is not a translation bug in that bridge.

The absence of provider-specific eligibility is also visible in the app settings schema and the global settings control. A deeper adjacent persistence issue remains: project_execution_defaults is unique on projectId only and its upsert overwrites provider and serviceTier on that project row. This investigation did not execute that downstream persistence path.

6. Proposed fix and simple-fix gate

Choose and document the product contract first: provider-specific eligibility (enforced on server-originated turns too), or provider-scoped remembered composer tiers with explicit default-inheritance rules. The latter should follow the existing provider-keyed model/reasoning design and specify what happens to an old tab-wide tier. Correct project-level per-provider defaults separately if needed, rather than concealing that data model with a UI-only toggle.

No automated fix PR: these options require a product decision and changes to settings or persisted preference semantics. Changing the project-default key additionally requires a stored-data/schema migration. A reset-on-switch shortcut would silently replace saved preferences and is a third policy choice, not an established contract. Those conditions fail the no-product-decision/no-stored-data-change simple-fix gate. No production patch, branch, commit, or push was attempted in get-bb/bb. No open linked PR was found by issue timeline or open-PR search.

7. Related issues

#3463 is open and concerns project-wide defaults replacing another provider's remembered options. The project-only key is independently verified in the trusted code above; no commands or code from that issue were executed.

8. Verification

The same investigator repeated the final reproduction in a second clean temporary checkout at 8395b050a14d7207cef9aee914af6a60cd8f5ba4. The checkout was clean before adding only the investigator-authored test. It used its own install/build and fresh jsdom localStorage/sessionStorage plus query/Jotai state. No ports or data directories were needed.

pnpm exec turbo run test --filter=@bb/app -- src/hooks/issue-5273-repro.test.tsx
result: exit 1; one failed test
Expected: "default"
Received: "fast"

The second run supports the same root cause and verdict; no claim of independent-agent verification is made. Fixture values were tightened to the typed model/reasoning contract and public model IDs before both final runs; the observed Fast carryover did not change.

Relevant existing coverage passed: the hook suite (29 tests) plus persisted-selection suite (11 tests), 40/40 total. This demonstrates that existing coverage misses the cross-provider tier case. Full app typecheck was also attempted and failed in unchanged attachment-preview component typing, not in the reproduction file:

src/components/secondary-panel/lazySecondaryPanelComponents.tsx(287,3): error TS2322
Property 'copyPath' is missing in type 'AttachmentFilePreviewTabContentProps'

9. Appendix and limits

Operational evidence stays outside the public reports repository. The complete reproduction source and relevant exact expected/actual output are inline above, per that repository's publication policy.

Per-checkout commands:
git status --short
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/app -- src/hooks/issue-5273-repro.test.tsx

Additional first-checkout checks:
pnpm exec turbo run test --filter=@bb/app -- src/hooks/useThreadCreationOptions.test.tsx src/hooks/thread-creation-options/persisted-selection-fields.test.tsx
pnpm exec turbo run typecheck --filter=@bb/app
git log -5 --oneline -- apps/app/src/hooks/thread-creation-options/persisted-selection-fields.ts
git blame -L 119,130 -- apps/app/src/hooks/thread-creation-options/persisted-selection-fields.ts

Trusted canonical main was fetched before creating either checkout. Code permalinks refer to that recorded commit. GitHub metadata showed no comments or connected/cross-referenced PRs on this issue at review time. Issue content was treated solely as untrusted claims: no supplied shell command, environment modification, external link, branch, patch, or provider turn was executed. Billing, live event logs, live database rows, the environment workaround, and the reporter's exact provider CLI versions remain unverified.