Skip to content

feat(pi): route OpenAI GPT-6 models via Pi's configuration_update - #79

Merged
robertn702 merged 1 commit into
mainfrom
robertn702/pi-openai-gpt6-routing
Oct 14, 2026
Merged

robertn702 merged 1 commit into
mainfrom
robertn702/pi-openai-gpt6-routing

Conversation

@robertn702

@robertn702 robertn702 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Closes #78

Activation: the OpenAI path only works on a Pi release that includes pi#10930 (merged 2026-10-14 as 60ac3bc, unreleased after v1.2.0). On Pi 1.0.x–1.2.0 the GPT-6 virtual models are listed, but routing them fails with unsupported_model.

What changed

  • packages/pi/src/router.ts: registers reasoning-router/<id> for the OpenAI models in the core registry (gpt-6-astra, gpt-6-sol, gpt-6-luna, gpt-6.1-sol) as well as the Anthropic ones. Each routes to openai/<id> and returns the effort as thinkingLevel, with no before_provider_request rewrite.
    • Gated on the capability (api === "openai-responses" and compat.supportsMidConvoEffort === true), not on the Pi version.
    • PHYSICAL_PROVIDER became a provider-to-API map. message_end now matches the pending decision's provider instead of the hard-coded anthropic.
    • Sign in with ChatGPT on openai is rejected with unsupported_model, before classifying.
  • Tests: OpenAI registration and routing; rejection for a missing model, no flag (older Pi), flag false, wrong API, and ChatGPT OAuth; the new message can't trigger Pi's retry pattern; OAuth isn't checked for Anthropic; OpenAI decision logging matches on provider. The existing Anthropic tests are unchanged.
  • Docs: docs/harnesses/pi.md (status, summary, OpenAI cache section, step 4, lineage limitation, "Upstream first?"). The payload rewrite is now needed only for openai-codex. Also the "OpenAI models are not routed yet" line in packages/pi/README*.md (EN/CN/JA/KO).
  • Changeset: @reasoning-router/pi minor.

Verification

  • npm run check: typecheck and lint pass, 470 tests pass. The only Biome warning is an unused variable already in packages/classifiers/test/jev.test.ts.
  • npm run smoke:pi (Pi 1.0.4, Anthropic): PASS, unchanged.
  • Live check, using a throwaway script that isn't committed:
    • Setup: Pi built from earendil-works/pi main at b45e0eb (includes 60ac3bc), loading packages/pi/dist/extension.js with -e. A fake Responses endpoint and a fake sglang System One classifier both ran on 127.0.0.1. The key was sk-fake… and an HTTPS_PROXY pointed at a dead port, so nothing could leave the host. No real credentials, no paid calls.
    • Three pi -p turns in one session, classified high, high, low:
      reasoning {"effort":"medium"}  input [developer, user, cu:high]
      reasoning {"effort":"medium"}  input [developer, user, cu:high, assistant, user, cu:high]
      reasoning {"effort":"medium"}  input [developer, user, cu:high, assistant, user, cu:high, assistant, user, cu:low]
      
    • reasoning.effort stayed fixed, each request's input was a prefix of the next, and the decision log recorded high, high, low with cached reads on turns 2 and 3.
    • The same script on Pi 1.0.4 failed with reasoning-router unsupported_model: openai/gpt-6-sol is not an OpenAI Responses model with mid-conversation effort in this Pi, with no request sent.

Assumptions and limitations

  • ChatGPT detection: route() can see the credential type through ctx.modelRegistry.isUsingOAuth(model), which exists in 1.0.4 and main. On the openai provider the only OAuth login is Sign in with ChatGPT, so an OAuth login there is rejected. Pi's own check is stricter: any non-sk- key sent to api.openai.com. The extension doesn't read the key itself, so a non-sk- API key wouldn't be caught. It also rejects OAuth even with a custom baseUrl, where Pi would still send configuration_update; that's the conservative choice. The ChatGPT path is covered by unit tests only, because a live test would need a real OAuth login.
  • Thinking off: with thinking off, Pi sends reasoning.effort: "none" (and no include) instead of a configuration_update. A none decision on gpt-6-luna or gpt-6-sol therefore misses the cache on that request and the next. I documented this rather than stopping the classifier from choosing none on OpenAI; that could be a follow-up if it shows up in practice.
  • openai-codex is out of scope; upstream won't enable it until Codex CLI turns on features.reasoning_effort_override.
  • smoke:pi stays pinned to Pi 1.0.4 (Anthropic only). An OpenAI smoke can be added once a Pi release includes pi#10930.

Summary by CodeRabbit

  • New Features
    • Added routing for supported GPT-6 models to OpenAI on compatible Pi releases.
  • Limitations
    • Older Pi releases and ChatGPT sign-in do not support this routing. OpenAI Codex models remain unrouted; selecting none for certain GPT-6 models may bypass prompt caching.
  • Documentation
    • Updated the Pi guides to explain supported models, setup requirements, compatibility, and routing limitations.

…pdate

Pi main (pi#10930, merged as 60ac3bc) pins reasoning.effort and sends the
thinking level as configuration_update items for GPT-6 on the openai
provider, as it already does for Anthropic. The extension now registers a
virtual model per OpenAI model in the core registry and returns the effort
as thinkingLevel, with no before_provider_request rewrite.

Decisions (reversible):
- Gate on api openai-responses plus compat.supportsMidConvoEffort, not the
  Pi version; Pi 1.0.4 rejects these models with unsupported_model.
- Detect Sign in with ChatGPT with ctx.modelRegistry.isUsingOAuth() on the
  openai provider and reject it with unsupported_model. The extension does
  not read the API key, so a non-sk- key (which Pi also treats as ChatGPT)
  is not detected.
- A none decision on gpt-6-luna/gpt-6-sol is left as is and documented: Pi
  sends request-level effort for thinking off, missing the cache.
- openai-codex stays out of scope.

Closes #78
@robertn702

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6808c1e-5142-45bc-8676-3b44ddd304d0
📥 Commits

Reviewing files that changed from the base of the PR and between cfb9710 and 3db9646.

📒 Files selected for processing: 8
  • .changeset/pi-openai-gpt6.md
  • docs/harnesses/pi.md
  • packages/pi/README.md
  • packages/pi/README_CN.md
  • packages/pi/README_JA.md
  • packages/pi/README_KO.md
  • packages/pi/src/router.ts
  • packages/pi/test/router.test.ts

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

📝 Walkthrough

The Pi adapter now registers supported OpenAI GPT-6 models alongside Anthropic models. It validates provider API and effort support, rejects OpenAI ChatGPT OAuth, and matches completion events by provider and model. Documentation describes the route and its limitations.

Changes: OpenAI GPT-6 routing

Layer / File(s) Summary
Register and validate OpenAI routes
packages/pi/src/router.ts, packages/pi/test/router.test.ts
The router registers models for both Anthropic and OpenAI, then checks API compatibility and mid-conversation effort support. It rejects OpenAI models using Sign in with ChatGPT. Tests cover successful routing, rejection cases, and unchanged Anthropic OAuth routing.
Match completion events by provider
packages/pi/src/router.ts, packages/pi/test/router.test.ts
Pending requests record the provider. Completion events must match both provider and model before processing. Tests cover OpenAI event logging.
Document supported GPT-6 routing
docs/harnesses/pi.md, packages/pi/README*, .changeset/pi-openai-gpt6.md
The documentation describes the supported GPT-6 models, Pi’s configuration_update behavior, compatibility limits, and the exclusion of openai-codex. The changeset records the package update.

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Pi
  participant Router
  participant Classifier
  Pi->>Router: Request a virtual OpenAI model
  Router->>Router: Check API, effort support, and OAuth
  Router->>Classifier: Classify provider and model
  Classifier-->>Router: Return selected effort
  Router-->>Pi: Return thinkingLevel
Loading
Merge Risk: ⚪ Minimal · up to 3db96

The GPT-6 route is conditional on Pi support, with its credential and cache limitations documented. No identified issue prevents merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (6 skipped: 6… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: routing OpenAI GPT-6 models through Pi using configuration_update.
Linked Issues check Passed The PR satisfies the coding requirements in #78. packages/pi/src/router.ts registers the four specified GPT-6 virtual models for openai, routes them to matching openai/<id> models, returns `thin…
Out of Scope Changes check Passed The changed router logic directly implements #78. The new tests verify the required OpenAI and rejection paths and protect existing Anthropic behavior. The Pi documentation and localized README update…
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@robertn702
robertn702 merged commit 327ce5d into main Oct 14, 2026
4 checks passed
@robertn702
robertn702 deleted the robertn702/pi-openai-gpt6-routing branch October 14, 2026 16:16
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.

pi: route OpenAI GPT-6 models now that Pi sends configuration_update

1 participant