← reports

#6806 · Execution validation reuses a cached discovery timeout

Bug Priority: Medium Effort: Medium providers · workflows

2026-11-02 · GitHub issue · trusted base 916d684ac23d0b0de82c09cfc7553a50287d2188

Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro.

1. TL;DR

Workflow execution checks a model using an SDK lookup intended for a responsive model picker. A previous provider discovery timeout can therefore reject that check even after the host can list models again. An isolated test through the real SDK, HTTP route, model-catalog store, and migrated SQLite database reproduces this at both one and thirty-one seconds after the timeout. The server's validation-mode resolver succeeds immediately against the same recovered host fixture. Both cases repeat in a second clean checkout; historical macOS load and the original four failures were not recreated.

2. Claims vs findings

ClaimFindingEvidence
An immediate model lookup can reuse a cached timeout after recovery.VerifiedAt age 1,000 ms, the second SDK request returns timeout without making another model RPC.
Expiry does not make the failing lookup wait for refreshed data.VerifiedAt age 31,000 ms, the second SDK request starts another model RPC but still returns the cached timeout.
Validation can wait for recovery instead.VerifiedThe existing validation resolver returns the recovered model and no error in both cases, with two total model RPCs.
Workflow selection rejects before recording or dispatching an agent call.Verified by source traceSelection throws on the SDK error; runAgentCall awaits its identity before reading or inserting the call.
The reported macOS loaded-host window caused four failures.Not independently establishedNo production logs, real provider sessions, or historical runtime data were used.
A third-party environment hook caused the catalog failure.Not established and not neededNo such hook is installed in this reproduction. The core SDK/cache mismatch reproduces without it.

3. Environment

4. Minimal reproduction

  1. Use a clean checkout of the trusted base commit and install/build its existing dependencies:
    git checkout --detach 916d684ac23d0b0de82c09cfc7553a50287d2188
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build
  2. Save the complete test below as apps/server/test/providers/issue-6806-recovery.test.ts. It creates a discovery timeout through the actual host RPC boundary, changes the host answer to a healthy catalog, and retries through the same SDK interface workflows use. It also checks the real server validation resolver as a recovery control.
  3. Run:
    pnpm exec turbo run test --filter=@bb/server -- test/providers/issue-6806-recovery.test.ts

Expected for execution validation: a recovered host yields a catalog with modelLoadError: null after a bounded refresh. The intentionally failing assertion represents that execution expectation, not a request to make ordinary picker calls block.

Actual, verbatim diagnostic output from both runs (Turbo's task prefix omitted):

{"failureAge":1000,"initialError":"timeout","retryError":"timeout","requestsAfterRetry":1,"validationError":null,"totalModelRequests":2}
{"failureAge":31000,"initialError":"timeout","retryError":"timeout","requestsAfterRetry":2,"validationError":null,"totalModelRequests":2}

The regression fails in both cases at expect(retried.modelLoadError).toBeNull() after the validation control has already succeeded. Received error:

{
  "code": "timeout",
  "detail": "model list command_timeout",
  "providerId": "claude-code"
}
Test Files  1 failed (1)
Tests  2 failed (2)
Complete reproduction test
import { createNodeBbSdk } from "@bb/sdk";
import { describe, expect, it } from "vitest";
import { resolveSystemExecutionOptionsForValidation } from "../../src/services/system/execution-options.js";
import { registerHostRpcResponder } from "../helpers/host-rpc.js";
import {
  catalogAnswer,
  errorAnswer,
  healthAnswer,
  installCatalogStore,
  modelList,
} from "../helpers/provider-model-catalogs.js";
import {
  seedEnvironment,
  seedHostSession,
  seedProjectWithSource,
} from "../helpers/seed.js";
import { withTestHarness } from "../helpers/test-app.js";

describe("issue 6806 recovered provider discovery", () => {
  it.each([1_000, 31_000])(
    "refreshes a failed SDK model lookup after recovery at age %i ms",
    async (failureAge) => {
      await withTestHarness(async (harness) => {
        const clock = { now: 1_800_000_000_000 };
        installCatalogStore(harness, { clock });
        const { host, session } = seedHostSession(harness.deps, {
          id: "host-issue-6806",
        });
        const { project } = seedProjectWithSource(harness.deps, {
          hostId: host.id,
          path: "/tmp/issue-6806-fixture",
        });
        const environment = seedEnvironment(harness.deps, {
          hostId: host.id,
          projectId: project.id,
          path: "/tmp/issue-6806-fixture",
        });
        let recovered = false;
        let modelRequests = 0;
        registerHostRpcResponder(harness, {
          hostId: host.id,
          sessionId: session.id,
          handle: (request) => {
            if (request.command.type === "provider.health") {
              return healthAnswer("ready");
            }
            if (request.command.type === "provider.list_models") {
              modelRequests += 1;
              return recovered
                ? catalogAnswer(modelList("recovered-model"))
                : errorAnswer("command_timeout");
            }
            throw new Error(`Unexpected RPC ${request.command.type}`);
          },
        });
        const sdk = createNodeBbSdk({
          baseUrl: "http://localhost",
          fetch: async (input, init) =>
            harness.app.request(new Request(input, init)),
        });
        const query = {
          environmentId: environment.id,
          providerId: "claude-code",
        };
        const initial = await sdk.providers.models(query);
        expect(initial.modelLoadError?.code).toBe("timeout");
        expect(modelRequests).toBe(1);

        recovered = true;
        clock.now += failureAge;
        const retried = await sdk.providers.models(query);
        const requestsAfterRetry = modelRequests;
        const validated = await resolveSystemExecutionOptionsForValidation(
          harness.deps,
          query,
          null,
        );
        expect(validated.modelLoadError).toBeNull();
        expect(validated.models.map((model) => model.model)).toContain(
          "recovered-model",
        );
        console.info(
          JSON.stringify({
            failureAge,
            initialError: initial.modelLoadError?.code,
            retryError: retried.modelLoadError?.code,
            requestsAfterRetry,
            validationError: validated.modelLoadError,
            totalModelRequests: modelRequests,
          }),
        );
        expect(retried.modelLoadError).toBeNull();
      });
    },
  );
});

Test SHA-256: 09466cf2283e1dc491f6aa0a49973d976c30876d4c7437348bd66b51faf64443. Raw logs and the test are retained locally, not committed to this public report repository.

5. Root cause

  1. Workflow validateSelection calls bb.sdk.providers.models, then throws whenever the response contains a model-load error. The exact source error template is Could not load models for provider ${requested.provider}: ${catalog.modelLoadError.code}.
  2. SDK providers.models uses readExecutionOptions, which sends a request to system/execution-options. The server route uses the picker resolver, not the validation resolver.
  3. The two server resolvers select different access semantics. Picker access returns promptly; validation access waits when no usable catalog exists.
  4. Catalog evaluate first handles a usable catalog or a completed refresh. With neither, validation waits. Picker access serves an active cached failure; after expiry, a timeout is still served while a refresh runs in the background. Thus waiting thirty seconds does not make that very lookup authoritative.
  5. Workflow agent identity calculation invokes selection validation. runAgentCall awaits that identity before accessing the stored call. A cached discovery failure therefore aborts this stage, rather than reaching a host that could now execute the agent.

This is an access-intent mismatch across the SDK boundary, not proof that the picker cache is broken. No cause for the original host timeout or environment-fingerprint churn was established. The introducing commit remains unknown.

6. Proposed fix and simple-fix safety

Expose explicit execution-validation intent through the existing SDK/server model lookup path, and use it for workflow selection. Reuse the catalog store's current validation semantics so a fresh provider failure still propagates, concurrent refreshes coalesce, and picker latency stays unchanged. Add coverage for recovered timeout, persistent fresh failure, cancellation, and ordinary picker responsiveness.

No automated pull request. The current SDK argument contract and public execution-options query have no validation-intent field. Correctly carrying that intent requires a public API/schema change across SDK, server contract, server route, and workflow caller. That exceeds this rule's one-subsystem/no-public-schema-change gate. A delayed polling workaround instead introduces an unsupported retry policy and still consumes picker responses; it is not the smallest demonstrated root-cause repair. No production patch was made or pushed.

No open linked pull request was found via issue cross-reference metadata or an open-PR search for issue 6806. Main was fetched again after reproduction and remained at the recorded base.

7. Verification

The same agent created a second clean detached worktree from the recorded trusted base, installed frozen dependencies, built the existing Plugin SDK runtime, copied only the authored test, and reran the identical Turbo command. This is a repeated clean check, not an independent-agent review.

second="$(mktemp -d)"
git worktree add --detach "$second" 916d684ac23d0b0de82c09cfc7553a50287d2188
cd "$second"
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build --filter=@get-bb/plugin-sdk
# Add the exact test shown above, then:
pnpm exec turbo run test --filter=@bb/server -- test/providers/issue-6806-recovery.test.ts

Both runs executed the tests (not cached results). Both produced the two identical diagnostic rows and failed exactly at the intended null-error assertion. First run: 02:06:49 UTC, 9.95 s Vitest duration; second run: 02:06:58 UTC, 9.74 s. Each case's control returned the recovered model with no error.

An initial fixture setup used a non-local HTTP authority and was correctly blocked by host validation. Changing the test authority to localhost fixed that setup-only failure before either result above was recorded. No product behavior or security check was changed. The second clean run required no report correction.

8. Related issues

#6792 concerns workflow handling of inherited reasoning settings, a different selection-validation failure. It does not establish a duplicate of this cache-intent mismatch.

9. Appendix and limits

The report is nonvisual; no screenshot is needed. The fixture supplies a timeout response and a recovered model at the host RPC boundary. It does not manufacture a catalog failure directly or copy functions out of a bundle. No workflow or real review worker was launched, so pre-dispatch ordering is supported by the pinned source trace rather than a full workflow execution recording.

Repository-native adjacent check: pnpm exec turbo run test --filter=@bb/server -- test/providers/provider-model-catalog-store.test.ts: 30 tests passed (02:08:16 UTC, 11.91 s Vitest duration). This exercises the existing negative-cache and validation contracts separately from the new expected-failure test.

Issue text and comments were treated as untrusted claims. No issue-provided scripts, branches, patches, external links, or linked PR code were executed. Investigation used only trusted main and the test authored from its existing harness and contracts.