Skip to content

Ask Thalamus routing for every vault API-key request - #15

Merged
ualtinok merged 3 commits into
mainfrom
routing-api-keys
Nov 12, 2026
Merged

ualtinok merged 3 commits into
mainfrom
routing-api-keys

Conversation

@oaiauth-alfonso

@oaiauth-alfonso oaiauth-alfonso Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

When Thalamus started the host, every request that would use a vault API key first asks Thalamus routing which key to use, and sends only on routing's pick.

  • A routing refusal stops the request: nothing is sent, and the user sees "Thalamus routing declined this request, so it was not sent."
  • No answer within 1.5 s, or routing unreachable, also stops it: "Thalamus routing did not answer, so this API key request was not sent." This follows the ruling that paid API keys never send on the plugin's own choice while routing is away.
  • Subscription (OAuth) rows keep today's choice and aren't routed yet.
  • After an admitted send, an OpenRouter credits refusal or a DeepSeek 402 balance refusal is reported to routing as credential_refused.
  • Outside Thalamus nothing changes.

Moves to common-auth 0.47.0.


Summary by cubic

Makes every vault API-key attempt ask Thalamus routing which key to send, and sends only on routing's pick. A routing refusal, or no answer within 1.5 s (including an unreachable router), stops the request before anything is sent; both cases show a fixed message. Pi requests with no session id also stop with the no-answer message. Subscription (OAuth) rows are not routed yet and keep today's selection, and nothing changes outside Thalamus.

Routing

  • Routing picks among enabled API-key rows for the request's provider, covering titles, compaction, and retries.
  • A retry asks routing again and excludes every tried key; a 401 rotates to a newer version of the same admitted credential without another routing call.
  • Same-origin redirects make one routing call and keep the admitted key.
  • Qualifying balance refusals (OpenRouter credits, DeepSeek 402) are reported back to routing as credential_refused; user-set spending caps are not.

Adoption

  • @cortexkit/common-auth is bumped to 0.47.0 across the core, opencode, and pi packages.
  • Routing-admitted sends skip the plugin's rate-limit and balance cooldowns; vault authorization and the user's on/off switch still apply.

Written for commit c7fe6f6. Summary will update on new commits.

View guided diff Turn on auto-fix

Adopt common-auth 0.47 opt-in routing refusals for API-key attempts on all hosts, preserving the plugin's usual OAuth subscription path. Refusals and missing answers stop paid requests; qualifying balance refusals report the selected vault identities.

Carry OC1 host session ids through a private stripped header. Avoid consumer.send's internal paid-key 401 resend without routing admission. Add filtered unit and real-host no-send regressions; preserve xAI OAuth billing expectations. Pi real-host assertions include its existing SDK 400 JSON envelope around the fixed text.
Use consumer.send for routed core attempts, validating credential identity inside dispatch so a newer version of the same credential can retry a 401 without another routing call. Preserve the host-owned OpenCode2 send path and explain its cooldown bypass flag.

Same-origin redirects belong to one admitted request, so replace the prior redirect re-selection test with one-key/one-routing-call coverage. Replace the no-rotation claim with regressions for same-credential version rotation on OC1 and Pi. DeepSeek balance reports always use http_402, including bodies with generic request error codes.
@socket-security

socket-security Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​cortexkit/​common-auth@​0.44.0 ⏵ 0.47.089 +210079 +196 +1100

View full report

Replace the billing helper's module-level afterEach with per-test routing-accessor restoration, and restore only the original vault relay/host marker after nested installations. Restore direct accessor removals and Pi profile environment changes per test as well.

Handle Pi contexts without sessionManager: API-key routing sees no session and stops without sending, while non-routed serving remains unchanged. Add a two-file Bun subprocess regression for cached helpers and a Pi missing-session regression.

Authorized CI diagnosis: root bun test went from 482 pass/79 fail/83 skip to 562 pass/0 fail/83 skip; the full Pi CI command went from 38 pass/22 fail/2 skip to 61 pass/0 fail/2 skip under Bun 1.4.4 and Node 24.
@ualtinok
ualtinok merged commit c7fe6f6 into main Nov 12, 2026
20 checks passed
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