Skip to content

fix(routing): keep sticky requests in strict pools - #234

Open
lubshad wants to merge 1 commit into
ndycode:mainfrom
lubshad:fix/sticky-strict-pool-routing
Open

fix(routing): keep sticky requests in strict pools#234
lubshad wants to merge 1 commit into
ndycode:mainfrom
lubshad:fix/sticky-strict-pool-routing

Conversation

@lubshad

@lubshad lubshad commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary\n- keep sticky routing within strict model account pools\n- report actual attempted, unsupported, and unavailable accounts in routing errors\n- add strict-pool sticky routing regression coverage\n\n## Verification\n- npm test\n- npm run typecheck\n- npm run lint\n\nNote: this branch is based on the fork's current main, which is ahead of upstream main.

Summary by CodeRabbit

  • Bug Fixes
    • Improved model routing diagnostics by distinguishing attempted, unsupported, and unavailable accounts.
    • Corrected entitlement and service-unavailable messages so they accurately reflect the accounts evaluated.
    • Strict model pools now return clearer errors without unnecessarily checking accounts outside the configured pool.
    • Sticky routing stays on the current eligible account and advances appropriately when needed.

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

this pr adds request-local accounting for attempted and unsupported accounts and improves terminal routing diagnostics. it also adds vitest coverage for strict-pool errors and sticky selection, but lacks coverage for legacy workspace keys that expand to multiple business seats.

  • records accounts that reach upstream fetch and receive unsupported-model responses
  • reports attempted, unsupported, and unavailable account counts in routing errors
  • adds strict-pool and sticky-strategy regression tests

Confidence Score: 4/5

the strict-pool diagnostic count should be corrected before merging because multi-seat workspace pools can report false availability information.

the new unavailable-count calculation subtracts resolved account attempts from configured identity keys, so legacy workspace pools can produce incorrect operator-facing routing errors.

Files Needing Attention: index.ts, test/index.test.ts

Important Files Changed

Filename Overview
index.ts adds routing-attempt diagnostics, but strict-pool unavailable arithmetic mixes configured identity-key and resolved-account cardinalities
test/index.test.ts covers a single-key strict-pool exhaustion path but not legacy keys resolving to multiple business seats
test/rotation-strategy.test.ts adds valid sticky strict-pool regression coverage for behavior already present on the base revision

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[model pool keys] --> B[resolve matching account indexes]
  B --> C[select strict-pool account]
  C --> D[send upstream request]
  D --> E[record attempted or unsupported index]
  E --> F{another selectable pool account?}
  F -->|yes| C
  F -->|no| G[compose terminal routing error]
Loading
Prompt To Fix All With AI
### Issue 1
index.ts:3246-3249
**pool counts mix cardinalities**

when a legacy workspace key matches multiple business seats, `unavailableCount` subtracts attempted account indexes from configured identity keys, causing the strict-pool error to understate or omit unavailable accounts.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(routing): keep sticky requests in st..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

@lubshad
lubshad requested a review from ndycode as a code owner August 24, 2026 12:53
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 37da66ee-417a-4610-a626-c96f39e09fb4

📥 Commits

Reviewing files that changed from the base of the PR and between 2b35048 and 76cb0e2.

📒 Files selected for processing (3)
  • index.ts
  • test/index.test.ts
  • test/rotation-strategy.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Request routing now records attempted and unsupported accounts. Failure responses report accurate pool, unavailable, and entitlement counts. Tests cover strict-pool exhaustion and sticky account selection within configured pools.

Changes

Routing diagnostics

Layer / File(s) Summary
Track account outcomes
index.ts
Routing records accounts before upstream requests and when they reject a model. Strict-pool, general, and entitlement errors use attempted, unsupported, unavailable, and excluded account counts.
Validate pool routing and diagnostics
test/index.test.ts, test/rotation-strategy.test.ts
Tests verify that strict pools do not fetch general accounts after exhaustion, report attempted pooled accounts accurately, and keep sticky selection within the configured pool.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 76cb0

The change is localized to sticky routing behavior and its regression tests; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: ndycode

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the changes and verification, but it omits the required Compliance Confirmation and Notes sections and does not use the prescribed Testing checklist. Add the required Compliance Confirmation and Notes sections, and record the verification commands in the prescribed Testing checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: keeping sticky routing within strict model account pools.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread index.ts
Comment on lines +3246 to +3249
const unavailableCount = Math.max(
0,
preferredAccountIds.length - attemptedCount,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 pool counts mix cardinalities

when a legacy workspace key matches multiple business seats, unavailableCount subtracts attempted account indexes from configured identity keys, causing the strict-pool error to understate or omit unavailable accounts.

Context Used: speak in lowercase, concise sentences. act like th... (source)

Knowledge Base Used: Account rotation and selection

Prompt To Fix With AI
This is a comment left during a code review.
Path: index.ts
Line: 3246-3249

Comment:
**pool counts mix cardinalities**

when a legacy workspace key matches multiple business seats, `unavailableCount` subtracts attempted account indexes from configured identity keys, causing the strict-pool error to understate or omit unavailable accounts.

**Context Used:** speak in lowercase, concise sentences. act like th... ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))

**Knowledge Base Used:** [Account rotation and selection](https://app.greptile.com/zeian/-/custom-context/knowledge-base/ndycode/oc-codex-multi-auth/-/docs/account-rotation-and-selection.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant