Fall back to DeepInfra when the OpenCode Go usage limit refuses a CI OpenCode run
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
No issue: this fixes a CI incident from 2026-11-11.
Why we make these changes
The OpenCode Go subscription hit its weekly usage limit on 2026-11-11, and every CI OpenCode run has exited 1 within seconds since then. PR Review Checks reports "No result" (run). OpenCode threat detection fails all 4 attempts with engine_error (run), so warn mode publishes safe outputs with no verdict. David chose a DeepInfra fallback over Go's Extra Usage or a full switch.
Every CI OpenCode run now starts through run_with_fallback in .github/scripts/douwebot_opencode_run.py. That covers douwebot's OpenCode fallback, PR Review Checks and threat detection. The helper reruns on deepinfra/deepseek-ai/DeepSeek-V4.1-Flash only when all of these hold:
- Go exited non-zero and finished no step.
- Go's last
errorevent has typeprovider.go-limitorprovider.quota. OpenCode 2.2.5 gives an unretried quota rejection those types (to-session-error.ts). DEEPINFRA_API_KEYis set. Without it, behavior is unchanged.
New public surface
None, because this changes CI only. Douwebot receipts gain engine=opencode-deepinfra, and the review names deepinfra/deepseek-ai/DeepSeek-V4.1-Flash. PR Review Checks spans gain pr_review_checks.provider.
Also in this PR: both OpenCode stream readers now end an event only at LF. OpenCode's JSON.stringify leaves U+2028 raw, and splitlines() cut such an event and failed the review. A test reproduced the failure before the fix. THREAT_MODEL.md gains a pointer: on a fallback, DeepInfra receives the same PR content, fork content included.
Verification
- Fallback and no-fallback cases at each call site:
test_douwebot_opencode_run.py,test_gh_aw_opencode_detect.py,test_run_pr_review_check.py. Receipts:test_pr_gates.pyandtest_douwebot_config_approval.py. - Live probe with OpenCode 2.2.6 and a fake key:
deepinfra/deepseek-ai/DeepSeek-V4.1-Flashresolves under--standalone, and DeepInfra answers 401invalid_api_key. A misspelled model id givesprovider.no-routeinstead. agentic_workflow_guard.py checkpasses. All 12 locks were recompiled with gh-aw v1.2.1.
bots.yml, pr-review-checks.yml and their scripts run from main, so this PR cannot exercise its own change. The first real run comes after merge.
Lock security review:
- One new secret,
DEEPINFRA_API_KEY. It is in the detection post-step env and gh-aw's redaction list of every lock, and in thedouwebot-opencodeandPR Review Checksreview steps. - OpenCode receives that key only on a DeepInfra run. A Go run never sees it.
- No action, container or network changes.
- A DeepInfra run sends DeepInfra the same content Go receives, fork PR content included.
What changes for existing users
Nothing. This change is CI only.
PR decisions
2026-11-11 · fallback trigger matches the Go quota error · iter -
- Decision: Rerun on DeepInfra only on non-zero exit + no step_finish + last error type provider.go-limit or provider.quota + DEEPINFRA_API_KEY set
- Why: OpenCode 2.2.5 maps a Go usage limit to provider.go-limit, unretried (upstream test 'records OpenCode Console's Go usage limit 429 as a typed step failure without retrying'); a rejected key or outage stays visible
- Source: https://github.com/anomalyco/opencode/blob/v2.2.5/packages/core/src/session/to-session-error.ts
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · new receipt engine opencode-deepinfra · iter -
- Decision: Douwebot DeepInfra reviews publish engine=opencode-deepinfra; engine=opencode keeps meaning OpenCode Go
- Why: The published review must name the provider that served it, and existing receipts must keep validating
- Source: https://github.com/pydantic/pydantic-ai/blob/main/.github/scripts/publish_douwebot_review.py
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · one time budget across both runs · iter -
- Decision: The DeepInfra rerun gets only the rest of the detector deadline and the PR Review Checks max_minutes budget
- Why: A slow Go failure plus a full second budget would overrun the step timeout and lose the detector's status line
- Source: https://github.com/pydantic/pydantic-ai/blob/main/.github/workflows/AGENTS.md#opencode-threat-detection
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · THREAT_MODEL.md unchanged · iter -
- Decision: Document DeepInfra receiving PR content in .github/workflows/AGENTS.md, not THREAT_MODEL.md
- Why: THREAT_MODEL's CI section names no provider and says to keep option-level details in canonical component docs; the workflow rules are its canonical guidance
- Source: https://github.com/pydantic/pydantic-ai/blob/main/THREAT_MODEL.md#keeping-this-model-current
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · pre-push review 1 of 3 at 09aa91d38b7b70307417a971facd89cad775a169 · iter -
- Decision: reserved; dispatching fresh light-tier (Haiku) reviewer
- Why: tree 42b1962e2c06bbc8e989a06d0f83a4a994f5c0a3; full branch 451c51eb77c449b03387ed2d659cad61bc332ebc..09aa91d38b7b70307417a971facd89cad775a169; policy-base 451c51eb77c449b03387ed2d659cad61bc332ebc; first review
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · pre-push review 1 of 3 at 09aa91d38b7b70307417a971facd89cad775a169 outcome · iter -
- Decision: remediated in 198c91100: inlined the quota check (single-use helper rule), run_with_fallback hands each attempt its output stream so callers pass lambdas, provider attribute on the PR Review Checks span, one ImmediateTimer fixture; skipped THREAT_MODEL edit (see THREAT_MODEL.md unchanged entry)
- Why: Reviewed tree 42b1962e2c06bbc8e989a06d0f83a4a994f5c0a3; 5 findings, 4 valid, 1 resolved by the reviewer's own PR-body alternative
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · pre-push review 2 of 3 at 198c91100548523732e834d427a075bf3eb6550e · iter -
- Decision: reserved; dispatching fresh light-tier (Haiku) follow-up reviewer
- Why: tree 0d354fa03245761de753fbcdb1d71c3b38993038; follow-up scope 09aa91d38b7b70307417a971facd89cad775a169..198c91100548523732e834d427a075bf3eb6550e; policy-base 451c51eb77c449b03387ed2d659cad61bc332ebc
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · pre-push review 2 of 3 at 198c91100548523732e834d427a075bf3eb6550e outcome · iter -
- Decision: remediated in 558a4cf91: isinstance guard on the quota error type (regression from inlining), provider.quota test, THREAT_MODEL.md pointer sentence, receipt engine values owned by the review-gates section; 2.2.5 binary probe not run (install blocked by the auto-mode classifier)
- Why: Reviewed tree of 198c91100; 5 findings: 4 fixed, 1 a verification gap that cannot run here
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · THREAT_MODEL.md gets a pointer sentence · iter -
- Decision: Add one sentence to THREAT_MODEL.md 'Repository CI and agentic workflows' pointing at .github/workflows/AGENTS.md#opencode-falls-back-from-opencode-go-to-deepinfra; option detail stays there
- Why: Two independent pre-push reviews read the 'changes a trust or disclosure default' trigger as applying: fork PR content now can reach DeepInfra; a one-sentence pointer is cheap
- Source: https://github.com/pydantic/pydantic-ai/blob/main/THREAT_MODEL.md#keeping-this-model-current
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
- Supersedes: THREAT_MODEL.md unchanged
2026-11-11 · pre-push review 3 of 3 at 558a4cf91e4c251b0fd80be2c4fa5ba5b3c2b51b · iter -
- Decision: reserved; dispatching fresh light-tier (Haiku) follow-up reviewer; last allowed dispatch
- Why: tree 2c6bb3531af110ae9517b254f0ea947ade4af72a; follow-up scope 198c91100548523732e834d427a075bf3eb6550e..558a4cf91e4c251b0fd80be2c4fa5ba5b3c2b51b; policy-base 451c51eb77c449b03387ed2d659cad61bc332ebc
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · pre-push review 3 of 3 at 558a4cf91e4c251b0fd80be2c4fa5ba5b3c2b51b outcome · iter -
- Decision: remediated in 8edd8eaa5: OpenCode stream readers (fallback check and douwebot_opencode_result.final_text) split events at LF only, reproduced first by a failing test; annotated a test literal. Budget spent: no fourth review
- Why: Reviewed tree 2c6bb3531af110ae9517b254f0ea947ade4af72a; 4 findings: 2 fixed, 1 already met (tests green on 558a4cf91), 1 verification gap reported (2.2.5 binary)
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · final_text LF fix included · iter -
- Decision: Fix douwebot_opencode_result.final_text to split at LF only in this PR rather than a follow-up issue
- Why: Reproduced (failing test on 558a4cf91): a raw U+2028 in model text cut the event and failed every OpenCode review that read it; one line in the stream reader this PR's fallback check mirrors
- Source: https://github.com/pydantic/pydantic-ai/tree/opencode-deepinfra-fallback
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · PR Review Checks red on this PR is expected · iter -
- Decision: Do not chase PR Review Checks on this PR; it runs main's code against the spent Go quota, and this PR is the fix
- Why: David: "pr review checks will fail, this PR fixes it"
- Source: https://github.com/pydantic/pydantic-ai/pull/13158
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
2026-11-11 · merge main at d889cf44e: AGENTS.md conflict · iter -
- Decision: Kept both new top-level sections in .github/workflows/AGENTS.md (this PR's OpenCode fallback section and #13030's CI Linux runner section); no other conflict; no lock recompile needed
- Why: Merge queue marked #13158 UNMERGEABLE (CONFLICTING) after #13030 landed; review budget already spent, so no fourth pre-push review
- Source: https://github.com/pydantic/pydantic-ai/pull/13158
- Session: aae7335e-d3a1-43e4-9bbf-bff6a84cdacd
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
https://claude.ai/code/session_01NXARKgTQjEAA7jaYSyrSrf
Summary by cubic
When OpenCode Go refuses a CI run because of a usage limit, CI now retries with DeepInfra if DEEPINFRA_API_KEY is configured. Other failures keep their existing behavior.
- Applies to douwebot reviews, PR Review Checks, and OpenCode threat detection.
- Review receipts and telemetry identify which provider served the run.
- DeepInfra receives the same pull request content as OpenCode Go, including content from fork PRs.
- OpenCode stream readers now split events only at LF, preserving text that contains Unicode line separators.