Skip to content

CI: openai_codex provider (matrix check for upstream PR #1195) - #1

Merged
LeonWTW merged 1 commit into
mainfrom
feat/openai-codex-provider
Aug 4, 2026
Merged

CI: openai_codex provider (matrix check for upstream PR #1195)#1
LeonWTW merged 1 commit into
mainfrom
feat/openai-codex-provider

Conversation

@LeonWTW

@LeonWTW LeonWTW commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Self-PR on the fork purely to run the CI matrix (Python 3.10-3.13 + ruff) for upstream TauricResearch#1195, whose workflow run is held at action_required pending maintainer approval.

Not for merging here. Close once the checks report.

Adds an `openai_codex` provider so a run can be billed to an existing
ChatGPT subscription instead of API credits.

It is the only provider here that does not authenticate from an env
var. It reuses the OAuth token the official Codex app/CLI stores in
`~/.codex/auth.json` (overridable with `TRADINGAGENTS_CODEX_AUTH_PATH`)
via `ProviderSpec.credentials_fn`, refreshes it when it nears expiry,
and writes the rotated refresh token back — not persisting it would log
the Codex client itself out.

The endpoint also rejects three things the shared OpenAI client sends by
default, so `CodexChatOpenAI` overrides them:

- `stream: false` and `store: true` are pinned as constructor kwargs; a
  class-level field default sets the payload but not langchain's
  streaming dispatch, so the non-streaming path would still be taken.
- `temperature` is filtered out in `get_llm`.
- Input items with role `system` return 400. Every agent prompt in this
  repo is a `ChatPromptTemplate` whose first message is a system
  message, so the first analyst node failed on its first call and the
  run stalled. `_get_request_payload` relabels those items `developer`,
  the Responses-API name for the same role. Adding `instructions` does
  not make `system` acceptable, and only the item list preserves
  ordering when several system messages reach one call.

Because subscription traffic hits transient overload errors far more
often than the paid API, the README suggests raising
`TRADINGAGENTS_LLM_MAX_RETRIES`.

Caveat, stated in the README too: this endpoint is undocumented and
unversioned, so OpenAI can change it without notice, and driving
subscription credentials from a third-party tool is not clearly
sanctioned by OpenAI's terms. Nothing else in the codebase changes
behaviour unless the provider is selected.

Tests: auth-file resolution/refresh/rotation, provider registration and
payload shaping, the CLI login preflight, plus an opt-in live smoke test
behind `-m smoke`. `pytest -q` is 614 passed / 5 skipped and
`ruff check .` is clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FFuMQCxPhTkWLwrCQ57tTp
@LeonWTW LeonWTW closed this Aug 1, 2026
@LeonWTW LeonWTW reopened this Aug 1, 2026
@LeonWTW
LeonWTW merged commit 8444c4a into main Aug 4, 2026
6 checks passed
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.

1 participant