Repository navigation
feat: run the generative roles on the local ChatGPT subscription - #251
Merged
Merged
Conversation
A provider with `auth: "chatgpt"` bills the ChatGPT plan Codex is signed in to on this machine instead of an API key. Akno reads the login from `$CODEX_HOME/auth.json` on every call and never refreshes it, because Codex rotates refresh tokens on use. `base_url` defaults to the Codex backend and `api` is always `responses`; a config that also sets `api_key` or another transport is refused rather than half-applied. The backend serves only streamed, stateless Responses calls and refuses `temperature`, so these calls stream and the terminal event is read as the response. A failure reported inside the stream surfaces with the backend's message. Embeddings and a Decisions or endpoint reranker need endpoints the subscription does not serve, so those roles resolve as unavailable with the fix in the reason. A missing or expired login makes the subscription roles unavailable without sending a request. Benchmarks that rebuild provider config carry `auth` through. API keys stay the default and the guided setup is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erve a call `fallback` on an `auth: "chatgpt"` provider names another provider that serves a generative call the subscription could not: no usable login, a refusal, a rate or usage limit, a server error, an unreachable backend, or a timeout with time left in the caller's deadline. The call keeps its role, model id and settings. An answer that broke its contract stands, because that is the model and not an outage. With no usable login the subscription is not tried at all. The failed attempt runs unobserved, so maintenance telemetry does not count a call the fallback answered as a degraded stage. Each fallback reports a typed `model_fallback` warning. Ops run inside a scope that collects them, and the result gains an optional `warnings` field beside an unchanged `status`, through every door. The protocol version does not move, because the field is optional. The CLI prints warnings unless `--json`, an index pass lists them with its own warnings, the service logs every fallback (once a minute per role and reason) so background work is heard, and `akno doctor` shows a warning on roles that are falling back. `fallback` is refused on providers other than `auth: "chatgpt"`, and when it names a missing provider or another subscription. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A provider with
auth: "chatgpt"bills the ChatGPT plan Codex is signed in to on this machine instead of an API key. API keys stay the default, and the guided setup is unchanged. Luna's main model already works this way.What the subscription serves
Probed against the Codex backend with invented prompts:
/responseswithgpt-6-lunaworks, including strict JSON schema, image input, every reasoning level andmax_output_tokens(withresponse.incomplete)./decisions,/embeddingsand/chat/completionsreturn 403.stream: trueandstore: false, and it rejectstemperature. It refuses models the plan doesn't offer withmodel_not_found.So each role picks its provider. Roles the subscription can't serve stay on an API-key provider.
Change
schema.ts,load.ts)auth: "api_key" | "chatgpt"on a provider. Withchatgpt,base_urldefaults tohttps://chatgpt.com/backend-api/codexandapiis alwaysresponses.api_keyor anotherapiis refused at load instead of half-applied.embedding, or adecisions/endpointreranker, at it resolves the role as unavailable, and the reason tells you to use an API-key provider.models/chatgpt.ts)$CODEX_HOME/auth.json(default~/.codex) on every check and call; Akno never caches or refreshes it, because Codex rotates refresh tokens on use.models/client.ts)stream: true, never sendstemperature, and reads the streamed body down to its terminal event.errorevent inside a 200 surfaces asrequest_failedwith the backend's message.auththrough.docs/configuration.md): a new "ChatGPT subscription" section, plus comments indefault.jsoncandlocal.example.jsonc.Reasoning levels differ between the routes
On invented arithmetic and date checks,
reasoning_effort: "low"on the subscription did no reasoning in 9 of 10 runs and got the arithmetic wrong. On the API,lowreasoned and answered correctly.mediumon the subscription matched the API'slow. Akno sends the configured level unchanged and the docs say to re-check a role's level when moving it.Fallback to the API (second commit)
fallbackon a subscription provider names an API-key provider that serves a generative call the subscription could not. The call keeps its role, model id and settings.model_fallbackwarning (role,provider,fallback_provider,reason,message).AsyncLocalStoragescope, and the op's result gains an optionalwarningsfield beside an unchangedstatus. This covers every door: socket, MCP, HTTP and in-process.--jsonis set.akno doctorshows a warning on roles that are falling back.fallbackon a non-subscription provider, or one naming a missing provider or another subscription.Tests
packages/core/src/models/chatgpt.test.ts(14 tests):CODEX_HOMEpnpm typecheck,pnpm lint,pnpm knip,pnpm check:repositoryandpnpm docs:doctorpass. Prettier passes on every changed file.packages/core/src/models/model-fallback.test.ts(8 tests):recallwhose expansion fell back returns the warningpnpm testunder Node 22: 191 files, 5,058 tests passed.pnpm format:checkflagspackages/core/src/ops/context.ts, which this PR doesn't touch.ModelClientwith invented prompts, API against subscription:akno doctorwith live probes passes every role, including the answer role's generation and verification checks.🤖 Generated with Claude Code