GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: quota-aware subagent model fallback chain (#374) by Wibias · Pull Request #391 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Jul 24, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

Implements quota-aware subagent model fallback for thread_spawn child turns (issue #374).

  • Adds subagentModelFallback and subagentModelFallbackPollMs config
  • Rewrites child spawn requests at the proxy choke point before routing
  • Skips quota-exhausted native models and recently failed routed models
  • Supports per-agent TOML model_fallback merge
  • Primes Codex pool quotas before spawn selection
  • Records quota-like subagent failures for short TTL health blocking
  • Adds /api/subagent-model-fallback management route
  • Injects fallback-chain guidance into v2 multi-agent guidance

Verification

  • bun run typecheck
  • bun test tests/subagent-model-fallback.test.ts tests/multi-agent-compat.test.ts

Closes #374

Summary by CodeRabbit

  • New Features
    • Added quota- and health-aware subagent model fallback that can automatically rewrite spawned targets and inject fallback guidance into multi-agent instructions.
    • Added a management endpoint to view/update the fallback priority chain and polling interval.
    • Added support for the {{fallback}} placeholder in multi-agent guidance.
  • Bug Fixes
    • Improved thread-spawn rate-limit/quota failure detection and attribution, with more accurate rerouting and underlying request model updates.
    • Added dynamic Codex home resolution so environment changes are reflected after import.
  • Tests
    • Added end-to-end tests for chain building/deduping, fallback selection, guidance rendering, and spawn reroute behavior.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners July 24, 2026 06:47
@github-actions github-actions Bot added the enhancement New feature or request label Jul 24, 2026
@coderabbitai

This comment was marked as outdated.

Sign in to view
coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Ingwannu
Ingwannu requested changes Jul 24, 2026
View reviewed changes

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requested fallback behavior is valuable, but the current implementation can repeatedly select an exhausted model or select against the wrong account. The unresolved findings are substantive: 429/402 are not classified, routed failures are cached under a different key than the configured slug, selection runs before pool account resolution and uses the main plan for pool accounts, native health is not account-scoped, the normal SSE path does not record failures, and combo/encrypted child paths can be rewritten incorrectly. Please rebuild the selection at the resolved routing/account boundary, validate configuration atomically, make the tests independent, resolve the current dev conflict, and re-request review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
Wibias marked this pull request as draft July 24, 2026 07:23
@Wibias
Wibias marked this pull request as ready for review July 24, 2026 18:25
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias

This comment was marked as outdated.

Sign in to view
@Wibias Wibias linked an issue Jul 25, 2026 that may be closed by this pull request
[Feature Request] Subagent model fallback chain with quota-aware auto-switching #374
Closed
@Wibias
Wibias requested a review from Ingwannu July 25, 2026 03:45
coderabbitai[bot]

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lidge-jun

lidge-jun commented Jul 25, 2026

Copy link
Copy Markdown
Owner

🔒 Under maintainer review — detailed feedback incoming

@lidge-jun (maintainer) has this PR in an active review pass. Please do not merge or close
it
until the detailed review lands; a full comment with specific file:line findings,
failure modes, and suggested fixes is being prepared.

This PR is not part of the current integration batch. It is held back deliberately —
either because it touches a security boundary that MAINTAINERS.md requires an explicit
security review for, because it needs to be split into reviewable units, or because it needs
a rebase onto changes landing in dev right now.

Heads-up on rebasing: dev is receiving a coordinated integration batch today. If this PR
touches the same files, expect to rebase after that batch lands. The upcoming review comment
will name the exact overlapping paths so you only have to do it once.

No action needed from you until then. Thanks for the contribution and for your patience.

Review tracker: devlog/_plan/260725_pr_issue_rework · marker posted by the maintainer review pass

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 25, 2026
feat(codex): add account-qualified model namespaces #426
Closed
@lidge-jun

lidge-jun commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Thank you for the substantial quota-aware subagent fallback work. I found three correctness blockers that need to be resolved before merge.

  1. src/codex/subagent-model-fallback.ts:275-281 starts quota refresh work with void and returns no promise. The caller at src/server/responses/core.ts:700-703 uses await maybePrimeSubagentQuota(...), but that await resolves immediately, so model selection can run on stale quota state. Return the actual refresh promise (with errors handled at the owning boundary) and add a deferred-promise regression proving selection waits for the refresh result.

  2. src/server/management/agent-settings-routes.ts:328-331 silently removes invalid entries with filter() instead of rejecting the request. That violates the management API's atomic validation contract: a typo can persist a partially truncated fallback chain while returning success. Validate every item first, return 400 with the offending index/value, and mutate config only after the whole payload is valid. Add a regression proving one invalid entry leaves the previous config unchanged.

  3. src/codex/subagent-model-fallback.ts:173-184 does not record ordinary rate-limit wording as a health block. Providers that report rate limiting without the currently recognized quota phrases remain eligible and are selected repeatedly. Normalize the existing rate-limit classifier into this health path and test representative generic 429/rate-limit messages without treating unrelated errors as quota exhaustion.

I appreciate the scope of this feature. The refresh must be truly awaited, settings updates must be atomic, and generic rate limits must participate in the same health block before the fallback chain is reliable.

Please also rebase onto current dev, which now includes #439's context-pressure fields in src/types.ts; preserve that public type contract.


Reviewed as part of a maintainer integration pass. dev moved to ebc62d1f today (7 PRs integrated); Cross-platform CI is green on ubuntu, macOS, and Windows.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wibias added 7 commits July 25, 2026 20:42
@Wibias
feat: quota-aware subagent model fallback chain (#374)
fb1320a
@Wibias
fix(subagents): harden quota-aware model fallback routing
f5ac7ad
@Wibias
fix(subagents): defer fallback until auth and record tee failures
449223e
@Wibias
fix(subagents): address PR #391 review feedback
e0eca6a
@Wibias
fix(subagents): address follow-up PR #391 review feedback
8cccf02
@Wibias
fix(subagents): harden fallback routing for #391
f7c8654
Ensure fallback selection skips stale provider-prefixed entries while still allowing valid raw vendor/model slugs, and cache native slug lookups so selection no longer times out under test load.
@Wibias
fix(subagents): await quota prime, atomic fallback PUT, shared rate-l…
8f467d2
…imit health

Make maybePrimeSubagentQuota return an awaitable refresh promise, reject invalid fallback-chain entries without truncating config, and route health blocks through the shared rate-limit/quota classifier.
coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Repository owner deleted a comment from coderabbitai Bot Jul 25, 2026
@Wibias
fix(subagents): settle fallback before normalize and share quota primes
04d6a5b
Release abandoned Codex probe leases on pre-upstream fallback reroutes, run virtual-model/effort/service-tier normalization only against the final route, allow encrypted children to reach native fallbacks, and coalesce concurrent quota primes with success-only TTL.
coderabbitai[bot]

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
test(subagents): use documented native slugs in encrypted fallback co…
b251999
…verage

Avoid gpt-5.5 in native-only encrypted spawn tests: with an isolated CODEX_HOME, nativeOpenAiSlugs() can resolve to DOCUMENTED_NATIVE_OPENAI_ADDITIONS only, which omits gpt-5.5 and made CI reject before native fallback.
Wibias added 3 commits July 25, 2026 22:16
@Wibias
fix(subagents): preview account before fallback and finalize terminals
19a1d55
Avoid leasing primary Codex auth before routed fallback selection, clamp effort from the final native route, and always invoke passthrough terminal callbacks for non-quota stream failures.
@Wibias
fix(subagents): classify fallback nativeness from resolved routes
dc3e500
Use routeModel and canonical/pool route metadata for encrypted eligibility and Codex quota checks instead of slug-only nativeSlugSet matching.
@Wibias
fix(subagents): require pool accounts from resolved routes
2fd77d8
Drop the global explicit-pool config probe. Pool candidates now require a usable preview account based on each candidate routeModel result, including default openai pool mode.
@Wibias
Wibias merged commit 4e5d010 into lidge-jun:dev Jul 25, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jul 25, 2026
fix(providers): honor saved baseUrl for alibaba-token-plan via override + choices #459
Closed
feat(kiro): honor native END_TURN and Opus 5 native reasoning effort #460
Closed
feat(cli): add ocx opencode launcher #461
Closed
fix(router): warn when a pinned provider discards a configured baseUrl #464
Closed
fix(gui): react-doctor shared foundations #466
Merged
refactor(gui): split Combos for react-doctor #467
Merged
refactor(gui): react-doctor cleanup for Startup/Debug/Storage/Usage #468
Merged
fix(gui): restore OpenAI account setup with canonical recovery gates #469
Merged
@Wibias
Wibias deleted the codex/issue-374-subagent-model-fallback branch July 27, 2026 03:53
This was referenced Jul 27, 2026
feat(codex): add account pause controls and bulk exhaustion action #565
Closed
fix: scope Spark cooldowns to its native quota #599
Merged
feat(codex): account pause controls and bulk exhaustion (takeover #565) #667
Merged
feat(codex): selection order for the account pool #715
Merged
fix(responses): reject expired forward continuations #749
Merged
This was referenced Aug 7, 2026
feat(codex): add opt-in provider-host circuit breaker #1243
Merged
fix(subagent): move per-role model fallback into opencodex config (#1190) #1210
Closed
feat(routing): fail over between policy candidates on retryable failures #1281
Merged
fix(agents): reroute recovered tasks through healthy fallback #1556
Merged
This was referenced Aug 15, 2026
[Bug]: management-triggered catalog convergence reports reason:"disk" with no disk failure and discards the original error #1784
Closed
fix(combos): let a local input-admission refusal actually hop the fallback chain #1864
Merged
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
fix(subagents): address PR lidge-jun#391 review feedback
cc52b4d
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
fix(subagents): address follow-up PR lidge-jun#391 review feedback
34e7666
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
fix(subagents): harden fallback routing for lidge-jun#391
0797e12
Ensure fallback selection skips stale provider-prefixed entries while still allowing valid raw vendor/model slugs, and cache native slug lookups so selection no longer times out under test load.
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
Merge pull request lidge-jun#391 from Wibias/codex/issue-374-subagent…
3888fb2
…-model-fallback

feat: quota-aware subagent model fallback chain (lidge-jun#374)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Feature Request] Subagent model fallback chain with quota-aware auto-switching

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Wibias @lidge-jun @Ingwannu
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.