CI: openai_codex provider (matrix check for upstream PR #1195) - #1
Merged
Conversation
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
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.
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_requiredpending maintainer approval.Not for merging here. Close once the checks report.