← reports

#6810 · Pi error events omit retry classification

Bug Priority: Medium Effort: Medium providers provider-pi provider-retry

November 2, 2026 · GitHub issue · trusted base 916d684ac23d0b0de82c09cfc7553a50287d2188

Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

Pi forwards failure text but does not classify its error events. A synthetic gateway failure reaches the real retry policy with errorInfo: null, so the policy declines to retry. This reproduces at the actual Pi translation and delta-assembly boundary without an account, a network outage, or a live user thread. The same failure was repeated in a second clean checkout by the same agent. Timeline text is not simply discarded: existing core formatting already reads the detail, and long details intentionally collapse to a generic title; the reported visual appearance was not independently driven in a browser.

2. Claims vs findings

ClaimFindingEvidence
Pi failure events omit structured classification.VerifiedFive regression cases fail on trusted main: RPC error, final assistant error, native retry, superseded settlement, and compaction failure. Events contain detail but lack errorInfo.
Transient Pi failures are not retried by the built-in retry policy.Verified for the reproduced errorThe actual retry policy declines the translated 502 error as not-retryable. With classification added, the identical policy schedules a retry at 60000 ms using the deterministic test clock.
Retry considers only category.InexactIt also checks HTTP status for unavailable and rate-limit failures. Both forms of metadata are absent from Pi events.
Failure text never appears in the timeline.Not established as a universal claimThe detail survives translation. Core uses short details as the title; over 80 characters, the title becomes generic and the detail remains separately available. No screenshot or live UI verification is claimed.
Reported frequency and successful manual retries establish every observed failure as transient.UnverifiedNo access to the reporter's runtime, journal, or accounts was used. A generic 422 remains a bad request, not evidence of a transient outage.

3. Environment

4. Minimal reproduction

  1. Check out the public repository at the recorded commit and run pnpm install --frozen-lockfile --prefer-offline.
  2. Save this investigator-written regression test as plugins/provider-pi/src/delta-translation.errors.test.ts. It exercises real production translation and assembly; it does not mock the classifier or retry policy.
import { expect, it } from "vitest";
import { experimental_createDeltaAssembler as createDeltaAssembler } from "@get-bb/plugin-sdk/provider-bridge/testing";
import { createPiDeltaTranslator } from "./delta-translation.js";

const message = "502 Bad Gateway";
const assistant = {
  role: "assistant", content: [], stopReason: "error", errorMessage: message,
};
it.each([
  { jsonrpc: "2.0", method: "error", params: { message } },
  { type: "agent_end", messages: [assistant] },
  { type: "agent_end", messages: [assistant], willRetry: true },
  { type: "agent_end", messages: [assistant], deferSettlement: true,
    settlementSuperseded: true },
  { type: "compaction_end", reason: "overflow", aborted: false,
    errorMessage: message },
])("preserves actionable Pi failure information", (event) => {
  const translator = createPiDeltaTranslator({
    resolveModelContextWindow: () => null,
  });
  const assembler = createDeltaAssembler({ providerId: "pi" });
  assembler.assemble({
    threadId: "error-test",
    deltas: translator.translate({ type: "agent_start" }),
  });
  const events = assembler.assemble({
    threadId: "error-test", deltas: translator.translate(event),
  });
  expect(events).toContainEqual(expect.objectContaining({
    type: "provider/error", detail: message,
    errorInfo: { category: "internal", httpStatusCode: 502, providerCode: null },
  }));
});

Run:

pnpm exec turbo run test --filter=bb-plugin-provider-pi -- src/delta-translation.errors.test.ts

Expected: all five cases pass, preserving a classified provider/error event. Actual on unchanged main, in both checkouts:

Test Files  1 failed (1)
     Tests  5 failed (5)

Representative assertion difference, with incidental event identifiers omitted:

Expected:
  "errorInfo": { "category": "internal", "httpStatusCode": 502, "providerCode": null }
Received:
  "type": "provider/error"
  "message": "Provider error"
  "detail": "502 Bad Gateway"
  (no errorInfo field)

To observe the actual retry-policy decision, run this JavaScript from the repository root:

node --conditions=source --import tsx --input-type=module <<'JS'
import { createPiDeltaTranslator } from './plugins/provider-pi/src/delta-translation.ts';
import { decideRetry } from './plugins/provider-retry/src/retry-policy.ts';
const translator = createPiDeltaTranslator({ resolveModelContextWindow: () => null });
const delta = translator.translate({ jsonrpc: '2.0', method: 'error',
  params: { message: '502 Bad Gateway' } })[0];
const failure = { errorInfo: delta.errorInfo ?? null, attemptNumber: 1, rateLimits: null };
console.log(JSON.stringify({ errorInfo: failure.errorInfo, decision: decideRetry({
  failure, availability: { kind: 'not-routed' }, maximumWaitMs: null, now: 0, random: 0,
}) }, null, 2));
JS

Verbatim output on trusted main:

{
  "errorInfo": null,
  "decision": {
    "kind": "decline",
    "reason": "not-retryable"
  }
}

5. Root cause

The RPC translation branch and assistant settlement branches construct provider.error deltas containing only a generic message, detail, and lifecycle flags. The compaction branch has the same omission.

{
  kind: "provider.error",
  message: "Provider error",
  detail: errorEnvelope.data.params?.message ?? "unknown error",
  settlesTurn: true,
}

The server's turn.failed builder reads that event and defaults absent errorInfo to null. The retry policy correctly requires classification or HTTP status, so the unclassified 502 becomes not-retryable.

Separately, core timeline formatting already uses raw detail for unclassified short errors and category-specific titles for classified errors. An arbitrary text dump is not required in the collapsed title. The patch preserves detail and allows the existing categorized display path to work.

6. Proposed fix and verified local patch

Classify Pi error text once at the translator boundary using existing ProviderErrorInfo categories and HTTP status, and attach it on all five error paths. Preserve existing text and settlement/retry flags. Map unavailable 5xx responses to internal, connection/timeouts to connection-failed, explicit overload to overloaded, 429 to rate-limit, authorization errors to unauthorized, and context overflow to context-window-exceeded. Keep unknown and non-retryable 4xx conservative; do not treat an unqualified 422 as transient.

No public schema, protocol, dependency, stored data, or retry-policy change is needed. Do not invent a quota reset: a 429 category alone still does not provide resettable rate-limit state to provider-retry. This bounded fix does not add that state or claim to solve every rate-limit recovery.

With the local patch, the identical policy probe returns:

{
  "errorInfo": {
    "category": "internal",
    "providerCode": null,
    "httpStatusCode": 502
  },
  "decision": {
    "kind": "retry",
    "sendAt": 60000,
    "reason": "Provider unavailable"
  }
}

7. Verification

The same agent repeated the reproduction in a second fresh detached worktree at the exact trusted commit. A fresh frozen installation and the same Turbo test command reproduced all five missing-errorInfo failures. An expanded version adds twenty classification cases; on unchanged production code all 25 fail for missing metadata. This is repeat verification, not an independent-agent review. The second run required no changes to the root-cause conclusion.

After the local fix:

pnpm exec turbo run test typecheck lint --filter=bb-plugin-provider-pi --filter=bb-plugin-provider-retry

Pi:             352 passed | 8 skipped (360)
Provider retry: 33 passed (33)
Tasks:          13 successful, 13 total

Both packages passed typechecks and lint. The 25 focused regression cases pass after the fix. Existing settlement tests were updated only to include newly populated errorInfo fields. An initial unrelated full-monorepo build hit a pre-existing SDK build-order problem in the GitHub plugin; focused Turbo dependency builds and all relevant checks completed successfully. The existing forkable-plugin test configuration is unchanged, following docs/forkable-plugins.md.

8. Related work

No open pull request linked to #6810 was present in issue timeline metadata or the open-PR search at investigation time. Related Pi reports found by area search concerned different session or streaming behavior, not this missing error classification. No linked pull-request code was checked out or run.

9. Appendix and trust boundary

Issue content was treated only as untrusted claims. The reproduction test and patch were designed from trusted origin/main source. No issue-provided script, URL, branch, patch, or binary was executed; no real runtime data or credentials were read. Exact test and policy commands, expected results, observed output, source permalinks, and second-run verification are included inline. Local raw logs and test files are retained only as ignored investigation artifacts, not published, in accordance with the report repository's privacy policy.