You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
runTurnLoop already sets UsageBypass=true for both wire formats when the per-installation gate engages, but only ProxyMessages consumes it via bypassToAnthropic (strict subscription pass-through, skip ledger, and on a retryable 429 fall through to routeFor). ProxyOpenAIChatCompletion ignores routeRes.UsageBypass entirely and continues normal dispatch. Happy-path OpenAI turns often look fine by coincidence (same decision + OAuth). The 429 fallthrough does not: Messages recovers via scorer reroute; OpenAI returns a raw 429 to the client.
Confirmed unintentional incomplete port (same class as #771): gate is shared; Anthropic bypass consumer was Messages-only in #512. No open PR implements this — #762 / #773 explicitly defer it.
Expected vs actual
Happy path (gate on, subscription has headroom, Anthropic-covered requested model)
Expected (Messages contract)
Actual /v1/messages
Actual /v1/chat/completions
Scorer
not called
not called
not called
x-router-decision
usage_bypass
usage_bypass
usage_bypass
Served model
caller-requested
caller-requested
caller-requested
Client
200
200
200
Path
bypassToAnthropic short-circuit
yes
no — normal OpenAI dispatch of the turn-loop decision
Billing
skip ledger (early return)
skip ledger
emitBilling with SubscriptionServed → delta=0 notional row
OTel
router.usage_bypass span
yes
no (normal upstream span path)
Happy path often “works” for the client on OpenAI — coincidence from the shared turn-loop decision, not parity with Messages’ dedicated consumer.
OpenAI: after runTurnLoop (service.go ~4188), immediately decision := routeRes.Decision with zero reads of routeRes.UsageBypass / bypassToAnthropic / errBypassRetryable.
bypassToAnthropic (usage_bypass.go ~227–369) skips scorer, planner, pin, semantic cache, and billing; on providers.IsRetryable pre-commit errors returns errBypassRetryable so the caller can reroute.
Codex-shaped UsageBypass (Decision.Provider == OpenAI) never enters bypassToAnthropic even on Messages — it already uses normal dispatch. This issue is specifically Anthropic UsageBypass consumption on the OpenAI wire (and the 429→routeFor contract).
But the gate already runs for OpenAI: TestUsageBypass_CodexSubscriptionPreservesRequestedModel asserts OpenAI usage_bypass headers + scorer skip. No doc says “OpenAI must not recover from bypass 429.”
No open PR implements this wiring. No closed issue declaring OpenAI UsageBypass out of scope.
Verdict: unintentional incomplete port — Messages-first implementation; OpenAI inherited the gate via the shared turn loop but never got the Anthropic consumer / fallthrough.
Live verification (Go fixture, main @ 5637f3c)
Mirrored bypassFixture / TestUsageBypass_BelowThreshold_SkipsScorer / TestProxyMessages_BypassWeeklyLimit_FallsBackToRoutedDispatch against both surfaces (same models: requested claude-sonnet-4-6, scorer pick claude-haiku-4-5, util 0.20, threshold 0.80, Claude OAuth on ctx).
Messages: status=200 decision="cluster:v0.2" model="claude-haiku-4-5" scorer=1
OpenAI: err=upstream returned status 429 (buffered) status=429
decision="usage_bypass" model="claude-sonnet-4-6" scorer=0 anthCalls=3
oai[0..2]: oauth=true src="subscription" err=429
Docker-stack curl was not used as primary proof: UsageBypass needs usage_bypass_enabled on the installation plus a controllable Anthropic 429, which the unit fixture exercises cleanly. Illustrative client shapes for the same surface (local stack) are below.
Illustrative curls (client surface)
Requires: seeded rk_… key, installation with usage_bypass_enabled=true, and a Claude subscription token in X-Weave-Anthropic-Subscription. Replace placeholders.
Messages (works today — including 429 recovery when upstream weekly-limits):
Post-dispatch baseline + subscription-credit retry — #773 does not wire bypassToAnthropic; at best a Weave-key retry after OAuth 429, not UsageBypass’s clear-flag + routeFor
On errBypassRetryable: subscription-only → refuse; else clear UsageBypass, refresh subsidy, load switch history, routeFor, continue normal OpenAI dispatch.
Align billing/telemetry with the chosen Messages parity (skip ledger vs delta=0 notional; router.usage_bypass span).
Acceptance criteria
OpenAI test mirroring TestUsageBypass_BelowThreshold_SkipsScorer: usage_bypass decision, requested model, scorer=0 (happy path — may already pass via coincidence; keep as regression).
OpenAI test mirroring TestProxyMessages_BypassWeeklyLimit_FallsBackToRoutedDispatch: buffered Anthropic 429 must not reach the client; scorer runs; routed decision/model served.
Subscription-only + bypass retryable → refuse (Messages parity), if that guard is ported.
Billing/telemetry behavior explicitly chosen and tested.
No change to ProxyMessages bypass behavior; no change when the gate is off.
Duplicate check
Searched open PRs/issues for UsageBypass / bypassToAnthropic / “usage bypass” on OpenAI consumption: none implement this. Closest mentions are deferrals in #762 and #773.
TL;DR
runTurnLoopalready setsUsageBypass=truefor both wire formats when the per-installation gate engages, but onlyProxyMessagesconsumes it viabypassToAnthropic(strict subscription pass-through, skip ledger, and on a retryable 429 fall through torouteFor).ProxyOpenAIChatCompletionignoresrouteRes.UsageBypassentirely and continues normal dispatch. Happy-path OpenAI turns often look fine by coincidence (same decision + OAuth). The 429 fallthrough does not: Messages recovers via scorer reroute; OpenAI returns a raw429to the client.Confirmed unintentional incomplete port (same class as #771): gate is shared; Anthropic bypass consumer was Messages-only in #512. No open PR implements this — #762 / #773 explicitly defer it.
Expected vs actual
Happy path (gate on, subscription has headroom, Anthropic-covered requested model)
/v1/messages/v1/chat/completionsx-router-decisionusage_bypassusage_bypassusage_bypassbypassToAnthropicshort-circuitemitBillingwithSubscriptionServed→ delta=0 notional rowrouter.usage_bypassspanHappy path often “works” for the client on OpenAI — coincidence from the shared turn-loop decision, not parity with Messages’ dedicated consumer.
Failure path (UsageBypass engaged, Anthropic returns buffered weekly-limit 429)
/v1/messages/v1/chat/completionsUsageBypass,routeFor(scorer)usage_bypassbypassToAnthropicfallthrough onmainSummary / mechanism
usageBypassEngaged/usageBypassDecisionininternal/proxy/usage_bypass.go;runTurnLoopsetsres.UsageBypass+ Decision{Provider: anthropic|openai, Model: requested, Reason: "usage_bypass"}(turnloop.go~357–361, ~571–574).ProxyMessagesatservice.go~2168:runTurnLoop(service.go~4188), immediatelydecision := routeRes.Decisionwith zero reads ofrouteRes.UsageBypass/bypassToAnthropic/errBypassRetryable.bypassToAnthropic(usage_bypass.go~227–369) skips scorer, planner, pin, semantic cache, and billing; onproviders.IsRetryablepre-commit errors returnserrBypassRetryableso the caller can reroute.Codex-shaped UsageBypass (
Decision.Provider == OpenAI) never entersbypassToAnthropiceven on Messages — it already uses normal dispatch. This issue is specifically Anthropic UsageBypass consumption on the OpenAI wire (and the 429→routeForcontract).Is this intentional? Checked, not assumed
bypassToAnthropic+ Messages consult; docs (internal/proxy/usage/CLAUDE.md) say “ProxyMessagespasses the request straight through”.turnLoopResult.UsageBypassgodoc names ProxyMessages.TestUsageBypass_CodexSubscriptionPreservesRequestedModelasserts OpenAIusage_bypassheaders + scorer skip. No doc says “OpenAI must not recover from bypass 429.”Verdict: unintentional incomplete port — Messages-first implementation; OpenAI inherited the gate via the shared turn loop but never got the Anthropic consumer / fallthrough.
Live verification (Go fixture,
main@5637f3c)Mirrored
bypassFixture/TestUsageBypass_BelowThreshold_SkipsScorer/TestProxyMessages_BypassWeeklyLimit_FallsBackToRoutedDispatchagainst both surfaces (same models: requestedclaude-sonnet-4-6, scorer pickclaude-haiku-4-5, util 0.20, threshold 0.80, Claude OAuth on ctx).Happy path
429 fallthrough
Docker-stack curl was not used as primary proof: UsageBypass needs
usage_bypass_enabledon the installation plus a controllable Anthropic 429, which the unit fixture exercises cleanly. Illustrative client shapes for the same surface (local stack) are below.Illustrative curls (client surface)
Requires: seeded
rk_…key, installation withusage_bypass_enabled=true, and a Claude subscription token inX-Weave-Anthropic-Subscription. Replace placeholders.Messages (works today — including 429 recovery when upstream weekly-limits):
OpenAI wire (gate engages; 429 does not recover like Messages):
Billing note (minor aside)
bypassToAnthropicsuccessemitBilling)emitBillingwithSubscriptionServed→ delta=0 + notionalNot an overcharge; different trail. Port should decide whether OpenAI should match Messages’ skip-ledger or keep the notional row.
Not the bug / not overlapping
bypassToAnthropic; at best a Weave-key retry after OAuth 429, not UsageBypass’s clear-flag +routeForFix
Wire Anthropic UsageBypass consumption into
ProxyOpenAIChatCompletionafterrunTurnLoop, mirroring Messages:routeRes.UsageBypass && Decision.Provider == Anthropic, run an OpenAI-wire equivalent ofbypassToAnthropic(or shared helper with format-specific emit/flush — same design call as ProxyOpenAIChatCompletion has no post-dispatch failover: OSS-outage baseline retry and subscription-credit retry both absent #771/fix(proxy): port post-dispatch failover to OpenAI chat completions #773).errBypassRetryable: subscription-only → refuse; else clearUsageBypass, refresh subsidy, load switch history,routeFor, continue normal OpenAI dispatch.router.usage_bypassspan).Acceptance criteria
TestUsageBypass_BelowThreshold_SkipsScorer:usage_bypassdecision, requested model, scorer=0 (happy path — may already pass via coincidence; keep as regression).TestProxyMessages_BypassWeeklyLimit_FallsBackToRoutedDispatch: buffered Anthropic 429 must not reach the client; scorer runs; routed decision/model served.ProxyMessagesbypass behavior; no change when the gate is off.Duplicate check
Searched open PRs/issues for
UsageBypass/bypassToAnthropic/ “usage bypass” on OpenAI consumption: none implement this. Closest mentions are deferrals in #762 and #773.