Skip to content

feat: expand OAuth subscriptions for inference and Gateway - #2562

Merged
hidb4ai merged 31 commits into
masterfrom
codex/oauth-subscriptions-python
Nov 22, 2026
Merged

hidb4ai merged 31 commits into
masterfrom
codex/oauth-subscriptions-python

Conversation

@PsiACE

@PsiACE PsiACE commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Which issue or RFC does this PR close?

Related: RFC 0016 and RFC 2086.

Rationale for this change

Make mainstream LLM subscriptions usable through the existing Pydantic AI and Rust Gateway paths.

What changes are included in this PR?

  • Support Codex, Copilot, Grok, Claude CLI, Gemini CLI, Qwen Code and Kimi Code through provider-specific adapters, public Pydantic AI interfaces, Authlib and Rust's oauth2 crate.
  • Add credential transactions, protocol conversions and Core admission profiles while preserving bound two-phase checks and pre-conversion response evidence for Core inspection.
  • Keep visible and thought text checks separate, preserve Gemini tool-call identities, and inspect buffered Responses streams before replaying their original bytes to Python SDKs. Reject actual SDK-derived identity collisions while retaining normal multi-summary reasoning, parallel tools and unrestricted ID spelling.
  • Reuse community golden fixtures and maintain attribution in LICENSES/oauth.md; update bilingual guides and required source headers.
  • Keep DSH automatic deadlines active until completion and clear timers on every exit.
  • Retain both existing 1.5-second observation budgets and all behavioral assertions in the scheduler overflow regression while using the deterministic retry clock from master.

Are there any user-facing changes?

New model prefixes and device-login commands. Protocol limits and credential ownership are documented; Python Claude CLI requires inference protection to be disabled. With continuations disabled, truncated output retains diagnostics and fails structured generation. Upgrade Core before Gateway to accept the additive original-response evidence field.

How was this change tested?

  • After merging master at 0b22a60f7, Python 3.12 inference, Core context-check, Code Assist privacy, usage-recorder and Responses privacy suites: 550 passed, 1 platform skip. Stream cases use the actual OpenAI SDK and Pydantic AI with controlled responses, including parallel tools, initial content, text/thinking/refusal assembly, interrupted streams and usage. Eleven additional cases cover derived reasoning/tool/file identity collisions and safe controls, including raw reasoning with summary 0; four collision cases fail against the previous head and pass with the fix.
  • Rust workspace: 283 passed, including real Core/UDS recovery and controlled provider HTTP/subprocess behavior.
  • After merging master, CI workflow, scope, shard, cache and local-action checks: 344 passed, 5 skipped. Scheduler tests: 25 passed. Injected early-retry and indefinitely-postponed-gate faults both fail the overflow regression. Usage-recorder recovery cases fail with an injected 60ms healthy write before the fix and pass after it; an independent SQLite listener confirmed an actual long-running query and SQLITE_INTERRUPT before successful recovery. The shared usage-recorder correction and CI download fixes are now in master.
  • make check passed after merging master; root, evaluation and Bub lock checks passed. Generated API and contract checks passed (69 tests).
  • On final PR head 70cd1539e, Main 45019934521 completed with 68 successful jobs, 22 conditional skips and two failed statuses. All twelve Python unit/E2E jobs, Gateway formatting/Clippy/workspace tests/upstream protocol TCK, website/docs, Harness scenario acceptance and four SQLite upgrade configurations passed. The sole original failure was Ubuntu cold bootstrap: downloading the uv installer failed with an SSL connection timeout before PowerContext installation. The final CI result failed as a consequence. The installer source is unchanged by this PR, and the failure was retained without rerunning or changing tests.
  • The squash merge b5177d87e has the identical Git tree. Its Ubuntu installer job passed on the first attempt, as did Gateway and Harness acceptance. Main 45020820484 still had two resource-candidate jobs pending at the last observation; this is not represented as a completed successful workflow.
  • Live acceptance on 2026-11-10 passed with existing Codex and GitHub credentials. On 2026-11-17, Codex passed native generation/artifact readback and Python direct/Gateway Responses tool round trips (ordinary and streamed); Copilot Chat and Responses calls returned provider HTTP 402, so its tool round trips remain unverified. Other subscriptions use community fixtures and controlled tests. Live provider acceptance was not repeated for these fixes.

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.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 07:06

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@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.

Two fixes are needed before merging: preserve Claude CLI truncation state and synchronize the dependent lockfiles. Details are inline.

Comment thread pyproject.toml Resolved
@PsiACE
PsiACE requested a review from frf12 as a code owner November 10, 2026 11:48
Copilot AI balanced review requested due to automatic review settings November 10, 2026 11:48

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 11:53

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@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.

@PsiACE, both previous findings are fixed at 7e9e15b. A reproducible Python 3.11 stdin deadlock remains in the Claude CLI tests and blocks CI; details are inline.

@hireview001 hireview001 left a comment

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.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 03:33

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@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.

@PsiACE, the Python 3.11 stdin deadlock and Code Assist candidate-count issue are fixed at 083f17e. One release-build regression remains: adding Authlib to the build-host group pulls in cryptography before pinned native preparation, breaking all three managed-resource candidate jobs. Details are inline.

Comment thread pyproject.toml Resolved
Copilot AI balanced review requested due to automatic review settings November 12, 2026 07:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@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.

Re-reviewed 7af7088. The missing-Content-Type SSE regression is fixed through the actual HTTP/UDS pipeline, and forbidden-content controls still block. The opaque SSE, Grok error, Claude composition and authentication-header fixes also pass focused checks. No additional correctness findings in this update.

The PR adds CLI/configuration/protocol contracts and extends /v1/context/check, so it does not meet the requested automatic-approval condition. No database tables or HTTP routes are added. CI is still running; provider and CLI validation here uses controlled fixtures, without renewed live-subscription acceptance.

@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.

Re-reviewed 55281d6 after the master/Scope sync. No new correctness findings in the merge delta. The generated contract identities agree, the combined OAuth/Scope Desktop qualification covers all 13 operations, and historical qualifications are preserved. Generated-code checks and the contract suite pass.

No database tables or HTTP routes are added. The PR still adds model/CLI/configuration/protocol contracts and extends /v1/context/check, so it does not satisfy the requested automatic-approval condition. This review did not renew live-subscription or installed Desktop GUI acceptance.

@frf12 frf12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed ceb62d07908137a4f43e6a76458681820ceb03d8. The Grok web-search concern is withdrawn after verifying Magpie's deliberate compatibility behavior and xAI's explicit unsupported-field contract. No remaining blocking code findings in my reviewed scope.

The existing E2E timeouts and downstream CI failures still need to be cleared before merge. Rust was source-reviewed; live-subscription acceptance was not renewed in this review.

for part in parts:
text = part.get("text") if isinstance(part, dict) else None
if isinstance(text, str):
fragments.append(text)

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.

[P1] Inspect visible Code Assist text separately from thoughts

A completed google-codeassist response containing visible text "sec", a thought part containing "padding", and visible text "ret" is inspected as "secpaddingret", while the Google SDK exposes "secret", allowing a forbidden value through with complete coverage. Inspect the concatenated visible and thought text separately before authorizing release.

.ok()
.filter(Value::is_object)
.unwrap_or_else(|| json!({"output":text}));
parts = vec![json!({"functionResponse":{"name":name,"response":response}})];

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 IDs for parallel Gemini tool calls

With two parallel calls to the same function, swapping the Chat results' tool_call_ids leaves the converted Code Assist payload unchanged because both native calls and responses discard IDs, losing the association between results and arguments. Preserve correlation IDs through both conversions, or reject this unsupported case before sending.

@hireview001 hireview001 left a comment

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.

  • Resolve merge conflicts with the target branch.

return self.decision(phase, "withhold", "content_field_unsupported")
if value.get("stream") is True and (not profile.allow_streaming or profile.protocol != "openai-chat"):
if value.get("stream") is True and (
not profile.allow_streaming or profile.protocol not in {"openai-chat", "openai-responses"}

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] Reject unsupported local Responses streams before sending

With enforcing protection and allow_streaming=True, this now admits Responses streams through ProtectedAsyncTransport, whose release path still uses the Chat-only inspect_sse, so successful Responses SSE calls consume provider quota before being withheld. Reject these streams before local dispatch or implement a compatible local release checker while preserving Gateway support.

@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.

Re-reviewed 8dd736a5d. The Code Assist channel separation, Gemini tool-call IDs, and local Responses-stream support fixes pass their focused checks. A new enforcing-mode disclosure remains: the Responses checker uses different part identities from Pydantic AI, allowing forbidden text to be assembled after approval. See the inline reproduction. @PsiACE @frf12 please address this before merging.

self.parts[output, content, kind].append(text)

def _sdk_part(self, kind: str, output: int, content: int, text: str = "") -> None:
self.sdk_parts.setdefault((kind, output, content), []).append(text)

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.

[P1] Reject collisions in SDK-derived reasoning identities

With enforcing protection forbidding secret, a Responses stream can emit sec for (output_index=0, item_id="rs_test", summary_index=1) and ret for (output_index=1, item_id="rs_test-1", summary_index=0), with normal added/done/completed events. I reproduced this on 8dd736a5d through ProtectedAsyncTransport and the actual Pydantic AI 2.64.0 client using a controlled upstream: the checker allows the stream, but ModelResponse.thinking contains padding\n\nsecret. Changing the second item ID to rs_other produces separate sec and ret parts.

Pydantic AI derives the vendor part ID as item_id for summary 0 and f"{item_id}-{summary_index}" otherwise, so these two different raw item IDs collide. This tuple key keeps them separate, and _identity() only checks raw item IDs, missing the content that the consumer actually concatenates. Reject derived-identity collisions, or inspect the same assembled content as the supported SDK before releasing the buffered stream.

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.

Verified fixed at 80556602a: replaying the original stream through ProtectedAsyncTransport and the actual Pydantic AI consumer now withholds it with output_identity_unsupported. The distinct-ID control still releases separate reasoning parts, and the ordinary forbidden-content control still blocks. This finding is addressed.

Adapt the scheduler clock and overflow regression from 53875d3 in #2726, retaining both existing 1.5-second observation budgets.
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.

@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.

Re-reviewed 80556602a, focusing on the changes since 8dd736a5d. The previously reported SDK-derived identity collision is fixed; the original enforcing-mode reproduction is now withheld while safe controls remain usable. No new blocking correctness findings in this update. The scheduler and usage-recovery test changes preserve the failure/deadline assertions while separating recovery from artificial short budgets.

No database tables or HTTP routes are added, but model/CLI/configuration/protocol contracts are added and /v1/context/check is extended. This does not meet the requested automatic-approval condition. CI is still pending. Validation used controlled provider responses and local SQLite; live subscriptions and Rust/host acceptance were not rerun in this incremental review.

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

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants