Skip to content

fix(anthropic): enforce model routes for vision and search helpers - #6371

Merged
lidge-jun merged 6 commits into
devfrom
fix/luvs01-676-anthropic-model-routes-20261001
Oct 1, 2026
Merged

lidge-jun merged 6 commits into
devfrom
fix/luvs01-676-anthropic-model-routes-20261001

Conversation

@luvs01

@luvs01 luvs01 commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Anthropic vision and web-search helpers could use the globally active OAuth account even when a model route excluded that account. Resolve helper credentials through the same per-model route as primary requests and carry the admitted configuration snapshot through sidecar planning and execution. An empty strict route is refused locally; a helper cannot silently use an excluded account.

Source history is preserved through commit 74e731eb6879d3931108536afd7bd98d00bcbd9d. The local validation below used the integration with dev at 0328373fb88fe0d019b29ae278e153d7fed4bcc7.

Verification

Current follow-up

Follow-up verification for 5540486ea6c7e80b7b9e6f1bfd1f8e7f9ed298e6:

Exercise the real vision-sidecar configuration path with synthetic routed Authorization and strict-empty no-transmission regressions; document independently routed vision and web-search helper models. Production runtime is unchanged.

Temporarily omitting the sidecar configuration caused both new regressions to fail. After restoring the unchanged runtime, the complete targeted model-route suite passed 48 tests with 259 assertions. The local docs build failed while creating a shared Vite cache directory (ENOENT); no successful local docs build is claimed. Hosted documentation CI is checked separately on this HEAD.

Executed focused commands:

  • bun test ./tests/adapters/anthropic/anthropic-model-routes.test.ts — passed.

Required typecheck, structure, privacy and file-size checks passed. Full local suite and unfiltered test:changed were not run; the documented focused/resource exception and remaining coverage limitations remain in effect. No blocked broad Kiro/SOCKS transport test or real-provider validation is claimed.

Cross-platform CI succeeded for this exact HEAD. Checkout 2630a789798dcd5a1623d4fe8fa431539d12e0e8 and the PR HEAD share tree fcd0750707006de8c5a5497fe82585c8bd068086. Skipped jobs remain skipped.

Independent maintainer approval, explicit security review and any required sponsorship remain pending before merge.

Earlier integration evidence

Current upstream integration: a6114b62ed1b65dede802359ccd373d913979b24; published HEAD 722345fc4fc32493cbadc784ae6d796a7f8be84a. The source history through 74e731eb6879d3931108536afd7bd98d00bcbd9d is retained without rewriting authors or commits. The PR-specific change was checked again after this integration; typecheck, structure, privacy and file-size gates passed. Cross-platform CI succeeded for this exact HEAD; its checkout tree matches the published HEAD tree. Skipped jobs remain skipped.

Windows, Bun 1.4.0, isolated test temporary directory:

  • bun test tests/adapters/anthropic/anthropic-model-routes.test.ts tests/responses/responses-state-snapshot-select.test.ts: initial run had 47 passed, 3 failed, and 2 errors from timeout/contamination. The three affected cases were retried unchanged with the existing five-second cap.
  • bun test tests/adapters/anthropic/anthropic-model-routes.test.ts --test-name-pattern "^(?:anthropic: a pacing-time pause skips a cooled successor for a healthy account, pool enabled=false|openai-responses: (?:pause with unusable survivors during pacing matches fresh admission|a pacing-time pause skips a cooled successor for a healthy account), pool enabled=false)$": 3 passed, 43 filtered, 0 failed, 18 assertions. This is a successful narrow retry, not a claim that the original combined run passed.
  • bun node_modules/typescript/bin/tsc --noEmit: passed.
  • bun scripts/structure-ssot.ts: passed.
  • bun scripts/privacy-scan.ts: passed.
  • bun scripts/file-size-ratchet.ts: passed.
  • git diff --cached --check 0328373fb88fe0d019b29ae278e153d7fed4bcc7: passed.

Focused fixtures use synthetic credentials and controlled provider responses. The full local suite and test:changed were not run under the focused-validation exception because concurrent isolated worktrees made the full suite impractical. The initial timeouts above remain part of the evidence. Exact-HEAD CI succeeded; results from another HEAD are not its verification.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Relevant contracts and regression coverage are recorded with the change.
  • Security-sensitive changes have independent maintainer review; sponsorship is required before merge where the sponsored-surface gate applies.
  • Author validation is documented for 5540486ea6c7e80b7b9e6f1bfd1f8e7f9ed298e6, known correct findings are addressed, and exact-HEAD CI is complete; author review readiness is confirmed.

Independent maintainer approval, explicit security review, and any required maintainer-sponsored decision remain pending before merge. These are separate from author review readiness; no approval or sponsorship is claimed.

Summary by CodeRabbit

  • New Features
    • Anthropic image descriptions and web searches now use the account selected by model routing, matching the routing behavior of regular requests.
    • When a strict route has no eligible account, these requests fail locally rather than falling back to another credential. Without account-pool configuration, existing stored-credential behavior is unchanged.
  • Documentation
    • Clarified how model routing and account selection apply to Anthropic image descriptions and web searches.

luvs01 and others added 5 commits September 29, 2026 00:46
The web-search sidecar test drives runAnthropicWebSearch end to end and asserts the captured Authorization header is the route-selected account's token. Also document in providers-and-adapters.md that helper sends share the model-route authority and a strict empty route fails the helper locally.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 9ceb4143-8f16-4d3f-a506-74cad371b2f2

📥 Commits

Reviewing files that changed from the base of the PR and between 722345f and 5540486.

📒 Files selected for processing (3)
  • docs-site/src/content/docs/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/reference/configuration/providers.md
  • tests/adapters/anthropic/anthropic-model-routes.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2708ac43-7ad3-4683-9243-03672159f405

📥 Commits

Reviewing files that changed from the base of the PR and between a6114b6 and 722345f.

📒 Files selected for processing (13)
  • src/oauth/anthropic-routing.ts
  • src/vision/anthropic-describe.ts
  • src/vision/index.ts
  • src/vision/plan.ts
  • src/web-search/alpha-search.ts
  • src/web-search/anthropic-executor.ts
  • src/web-search/index.ts
  • src/web-search/loop.ts
  • src/web-search/passthrough-bridge.ts
  • src/web-search/run-turn-loop.ts
  • src/web-search/sidecar-providers.ts
  • structure/providers-and-adapters.md
  • tests/adapters/anthropic/anthropic-model-routes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Anthropic vision and web-search sidecars now use model-route-aware token resolution when configuration is available. The sidecar paths retain and pass OcxConfig; tests cover routed credentials and strict-route rejection.

Changes

Anthropic sidecar authentication

Layer / File(s) Summary
Route-aware token resolution and validation
src/oauth/anthropic-routing.ts, tests/adapters/anthropic/anthropic-model-routes.test.ts, structure/providers-and-adapters.md
Adds getAnthropicSidecarAccessToken to resolve the model route and return the selected account’s pool token. Requests outside an enabled, configured pool use the standard token resolver. Tests cover routed credentials, strict-route rejection, and the web-search authorization header. Documentation describes the routing behavior.
Vision configuration and token flow
src/vision/plan.ts, src/vision/index.ts, src/vision/anthropic-describe.ts
The vision provider plan retains OcxConfig and passes it to describeImageAnthropic. That function uses the shared token helper with the provider name and model.
Web-search configuration and token flow
src/web-search/sidecar-providers.ts, src/web-search/alpha-search.ts, src/web-search/index.ts, src/web-search/loop.ts, src/web-search/passthrough-bridge.ts, src/web-search/run-turn-loop.ts, src/web-search/anthropic-executor.ts
The Anthropic web-search sidecar retains its configuration through provider resolution and execution paths. runAnthropicWebSearch passes the provider name, model, and configuration to the shared token helper.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant runAnthropicWebSearch
  participant getAnthropicSidecarAccessToken
  participant resolveAnthropicModelRoute
  participant AnthropicAccountPool
  runAnthropicWebSearch->>getAnthropicSidecarAccessToken: provider name, model, and config
  getAnthropicSidecarAccessToken->>resolveAnthropicModelRoute: resolve model route
  resolveAnthropicModelRoute-->>getAnthropicSidecarAccessToken: selected account
  getAnthropicSidecarAccessToken->>AnthropicAccountPool: obtain selected account access token
  AnthropicAccountPool-->>getAnthropicSidecarAccessToken: access token
  getAnthropicSidecarAccessToken-->>runAnthropicWebSearch: access token
Loading

Merge Risk: ⚪ Minimal · up to 72234

Anthropic vision and search helpers now use model-routed credentials and reject empty strict routes locally. No actionable merge-blocking defect is established; normal checks and required approvals still apply.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 72234

The change narrows which account may authorize helper requests and refuses routes without a permitted account. No newly introduced authorization bypass was established, but older calling conventions and concurrent configuration changes still need stronger assurance.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated security scope is selection among stored Anthropic accounts for vision and search traffic, including the account under which request content is processed and usage is incurred. Wider tenant, infrastructure or deployment authority was not established by the inspected evidence.

Trust Boundaries and Controls

  • observed — Strict routes constrain eligible account identities before credential acquisition. After refresh, account-specific acquisition rejects paused, missing, reauthentication-required, changed or expired credentials; expired background local-CLI credentials cannot adopt the global CLI identity.

Resilience and Maintainability Implications

  • observed — The credential snapshot is checked before its token is returned, but account identity and generation are not retained by the executors for validation before a later send or replay. Token-only execution predates this PR; its concurrent-revocation semantics remain an assurance limitation rather than a demonstrated new vulnerability.

Hardening Proposals

  • proposed — Separate legacy token lookup from routed helper execution so routed calls require configuration. Define whether authorization is fixed at admission or revocable before every send; enforce that choice through request-owned configuration and account-generation bindings where needed.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 12 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: applying Anthropic model-route enforcement to vision and web-search helpers.
Full details: Docstring Coverage

Explanation

Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 12 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@github-actions github-actions Bot added the bug Something isn't working label Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@luvs01
luvs01 marked this pull request as ready for review October 1, 2026 09:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T09:14:41.626011Z 722345f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 722345fc4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/vision/index.ts Resolved
Comment thread structure/providers-and-adapters.md Resolved
@luvs01
luvs01 marked this pull request as draft October 1, 2026 09:21
@luvs01

luvs01 commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Follow-up verification for 5540486ea6c7e80b7b9e6f1bfd1f8e7f9ed298e6:

Exercise the real vision-sidecar configuration path with synthetic routed Authorization and strict-empty no-transmission regressions; document independently routed vision and web-search helper models. Production runtime is unchanged.

Temporarily omitting the sidecar configuration caused both new regressions to fail. After restoring the unchanged runtime, the complete targeted model-route suite passed 48 tests with 259 assertions. The local docs build failed while creating a shared Vite cache directory (ENOENT); no successful local docs build is claimed. Hosted documentation CI is checked separately on this HEAD.

Executed focused commands:

  • bun test ./tests/adapters/anthropic/anthropic-model-routes.test.ts — passed.

Required typecheck, structure, privacy and file-size checks passed. Full local suite and unfiltered test:changed were not run; the documented focused/resource exception and remaining coverage limitations remain in effect. No blocked broad Kiro/SOCKS transport test or real-provider validation is claimed.

Cross-platform CI succeeded for this exact HEAD. Checkout 2630a789798dcd5a1623d4fe8fa431539d12e0e8 and the PR HEAD share tree fcd0750707006de8c5a5497fe82585c8bd068086. Skipped jobs remain skipped.

Independent maintainer approval, explicit security review and any required sponsorship remain pending before merge.

@luvs01
luvs01 marked this pull request as ready for review October 1, 2026 09:52
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration record (MAINTAINERS.md, dev only)

  • Exact head: 5540486ea6c7e80b7b9e6f1bfd1f8e7f9ed298e6. It is 2 commits behind origin/dev de8afe2e86, and git merge-tree --write-tree origin/dev is clean.
  • Hosted CI at this head: Cross-platform CI run 36843807626 passed on attempt 1 (pull_request). Every job that ran passed: test 1/4 through test 4/4, gates, structure gate, storage policy, docker smoke, api usage, docs site build, keyring, npm-global, and ci. React Doctor run 36843807683 passed. hygiene and enforce-target passed.
  • Local suites were not run, on the project owner's explicit instruction. Hosted CI is the only execution evidence.
  • Security review (OAuth account routing for sidecar helpers): an independent read-only review returned VERDICT: PASS — HEAD 5540486. Helpers resolve accounts through the same model route as primary traffic, and a strict empty route refuses before any send. Account selection only reads pool state (peek). Credentials come from getAnthropicPoolAccessSnapshot, which refuses paused, reauth-required or changed credentials. No tokens or account IDs appear in errors or logs.
  • Findings: correctness PASS. One non-blocking P3 remains for a follow-up. With the pool enabled, a helper refusal (paused, empty route or cooled) now shows the generic "OAuth authentication failed" text instead of the paused-specific message. Nothing leaks; only the diagnostics are less specific.
  • Attribution: author @luvs01, on a maintainer branch.

@lidge-jun
lidge-jun merged commit 22c890c into dev Oct 1, 2026
38 checks passed
@lidge-jun
lidge-jun deleted the fix/luvs01-676-anthropic-model-routes-20261001 branch October 1, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants