Skip to content

feat(gateway): add OAuth subscription transports - #2563

Merged
hidb4ai merged 14 commits into
codex/oauth-subscriptions-pythonfrom
codex/oauth-subscriptions-gateway
Nov 13, 2026
Merged

hidb4ai merged 14 commits into
codex/oauth-subscriptions-pythonfrom
codex/oauth-subscriptions-gateway

Conversation

@PsiACE

@PsiACE PsiACE commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Which issue or RFC does this PR close?

Related: Gateway RFC 2199. Stack 2/2, based on #2562; review and merge that PR first.

Rationale for this change

Consume mainstream LLM subscriptions in the existing Rust Gateway without adding another proxy service.

What changes are included in this PR?

  • Add provider-specific authentication and transports for Codex, Copilot, Grok, Qwen Code, Kimi Code, Gemini CLI and Claude CLI; standard grants use oauth2.
  • Preserve final-payload admission and checked release. Accept complete Codex SSE without Content-Type and normalize Copilot completion metadata for OpenAI clients.
  • Reuse shared OAuth fixtures and attribution from feat: expand OAuth subscriptions for inference and Gateway #2562; add live acceptance and deployment instructions.
  • Follow Magpie's allowed-tool filtering and per-request namespace restoration before release checks and JSON/SSE delivery; reject ambiguous aliases.
  • Reject duplicate JSON keys before response conversion, require Core approval for original and restored Grok carriers, and include cached input in Claude usage totals.

Are there any user-facing changes?

New subscription settings and device-login commands. Gemini context injection is disabled; Claude CLI is single-turn/text-only and rejected under enforcing or unknown Core protection.

How was this change tested?

From gateway/:

  • cargo test --locked --workspace -- --skip live_
  • cargo fmt --all --check
  • cargo clippy --locked --workspace --all-targets -- -D warnings

Commit hooks and documentation checks passed. uv run python tests/e2e/oauth_subscription_acceptance.py verified native Core generation, Gateway recall/capture and Core generation through the Gateway with existing Codex and gh credentials, using GPT-6 Luna and Claude Haiku 5.5. Authentication was enforced; inference protection was disabled for native adapters. --routes-only also passed OpenAI SDK consumption of JSON and SSE for Codex Responses and Copilot Chat/Responses; Codex Chat returns 501. The checks assert caller-visible output and completion behavior.

Other providers use controlled peers and migrated community cases. Magpie tool-selection and namespace cases cover send/release checks, JSON/SSE consumption and permitted degradation. The four legacy enforcing Core tests remain excluded because their helper omits Bearer authentication against localhost:8000.

AI usage statement

Implementation, documentation and tests were assisted by OpenAI Codex.

@AlexStocks AlexStocks added the 1.5.2 v1.5.2 release tracking label Nov 10, 2026
@PsiACE
PsiACE marked this pull request as ready for review November 10, 2026 07:06
@PsiACE

PsiACE commented Nov 10, 2026

Copy link
Copy Markdown
Member Author

Verified basic capabilities live with existing Codex and GitHub credentials (no new login). Other subscriptions rely primarily on migrated community test cases. Reviewers or contributors with those subscriptions are welcome to test them; subscription-specific fixes can follow in separate PRs and need not block this stack.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Grok Responses conversion needs to preserve tool-selection constraints and tool identities before this is ready to merge. Details are inline.

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The previous tool-selection and namespace issues are fixed. The new response restoration still loses raw JSON evidence before Core checks; details are inline.

…criptions-gateway

# Conflicts:
#	docs/en/docs/operate/deploy-server.md
#	docs/zh/docs/operate/deploy-server.md
#	gateway/README.md
#	gateway/crates/pc-gateway-core/src/executor.rs

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

renderer: &R,
mut raw: RawResponse,
) -> Result<RawResponse, ManagedOutcome> {
raw.body = renderer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Preserve upstream errors before restoring Grok identities

For a Grok Responses request containing namespaced tools, an upstream 502 with a plain-text or HTML body fails identity restoration and becomes HTTP 400 response_identity_unavailable, even during permitted passthrough. Restrict identity restoration to successful responses and retain the normal release-check path for upstream errors.

@hidb4ai
hidb4ai merged commit 9e9548d into codex/oauth-subscriptions-python Nov 13, 2026
1 check passed
@PsiACE
PsiACE deleted the codex/oauth-subscriptions-gateway branch November 16, 2026 12:52
hidb4ai pushed a commit that referenced this pull request Nov 22, 2026
* feat(inference): expand OAuth subscription support

* refactor(inference): isolate subscription providers

* docs(inference): clarify subscription setup and fixtures

* fix(inference): preserve Claude truncation and sync project locks

* fix(inference): reject length stops regardless of response state

* fix(inference): handle CLI EOF and Code Assist candidate counts

* fix(build): keep OAuth out of resource bootstrap

* fix(dsh): own the automatic operation deadline

* feat(gateway): add OAuth subscription transports (#2563)

* feat(gateway): add OAuth subscription transports

* refactor(gateway): isolate subscription providers

* docs(gateway): simplify subscription deployment guides

* fix(gateway): support live Codex and Copilot composition

* fix(gateway): preserve Copilot Chat SSE delivery

* fix(gateway): preserve subscription tool constraints and identities

* fix(gateway): preserve subscription response evidence

* fix(gateway): preserve Gemini stops and complete license headers

* fix(oauth): preserve response evidence and credential metadata

* test(desktop): qualify OAuth API contract against SQLite Server

* fix(oauth): preserve release and CLI composition contracts

* test(desktop): qualify merged OAuth API contract

* test(desktop): qualify OAuth and Scope contract together

* test(desktop): qualify OAuth and batch capture contract

* fix(oauth): preserve protected streams and tool identities

* ci: route Python tests to the 16-CPU runner profile

(cherry picked from commit 751d4cc)

* fix(inference): reject aliased Responses stream identities

* test(runtime): separate scheduler cooldown from wall time

Adapt the scheduler clock and overflow regression from 53875d3 in #2726, retaining both existing 1.5-second observation budgets.

* test(runtime): separate usage recovery from short deadlines

Reuse the recovery-budget fixes from #2726 commits 92e41b2 and 44f93be. Preserve the original 30ms interruption deadline and verify recovery on the same recorder and database.

---------

Co-authored-by: frf12 <rongfeng.frf@antgroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.5.2 v1.5.2 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants