Skip to content

Add Codex (ChatGPT subscription) provider with global login, per-role models, fallback, and docs#1022

Open
vivenstrix wants to merge 1 commit intoagent0ai:mainfrom
vivenstrix:feat/codex-chatgpt-subscription
Open

Add Codex (ChatGPT subscription) provider with global login, per-role models, fallback, and docs#1022
vivenstrix wants to merge 1 commit intoagent0ai:mainfrom
vivenstrix:feat/codex-chatgpt-subscription

Conversation

@vivenstrix
Copy link

This PR adds a new codex model provider to Agent Zero that uses local Codex CLI auth (ChatGPT subscription), not OpenAI API billing. It supports Chat/Utility/Browser roles, preserves per-role model selection, resumes Codex sessions per chat+role, and falls back per-call to the previous non-Codex provider on failures.

Global login works from Settings → Agent Settings → ChatGPT Subscription.
Chat/Utility/Browser can each use Codex (ChatGPT subscription).
Role model values persist independently after save/reopen.
Backend settings reflect role-specific model values.
Codex failure triggers temporary per-call fallback and warning, without changing saved provider.

Notes
Requires codex CLI installed and available in PATH.
Requires successful codex login.

Why
This will allow ChatGPT subscribers to use their subscription an NOT API usage:

  • global ChatGPT login
  • independent model choice for Chat/Utility/Browser
  • minimal setup (no API key for Codex mode)
  • resilient runtime behavior when Codex fails

What Changed
Provider + Runtime

  • Added codex to model providers.
  • Added runtime settings payload fields:
  • codex_status
  • codex_models
  • codex_login

Codex Execution Helper

  • Added python/helpers/codex_exec.py:
  • runs codex exec --json
  • supports fresh/resume calls
  • parses JSONL events for thread/message/errors
  • checks login status
  • supports login start/status/logout
  • fetches/refreshes available Codex models

Model Layer / Agent Integration

  • Added Codex chat wrapper integration in models.py.
  • Added per-chat + per-role thread persistence via AgentContext.data["codex_threads"].
  • Added Codex output normalization for chat role to avoid message/tool misformat loops.
  • Added per-call fallback to previous non-Codex provider/model snapshot with warning.
  • Passed role/context metadata from agent.py for Chat/Utility/Browser calls.

Settings + Fallback Snapshots

  • Extended settings with per-role previous provider snapshot keys (*_prev).
  • Snapshot logic keeps last non-Codex config for fallback.
  • Embedding path remains unchanged.

UI

  • Added "ChatGPT Subscription" section in Agent Settings.
  • Added connect/check/disconnect/refresh actions for Codex login/models.
  • In Chat/Utility/Browser settings:
  • hides API key input when provider is codex
  • shows Codex status panel + guidance link
  • allows Codex model selection per role
  • Fixed UI binding/display issue where role selectors appeared to show same model despite distinct backend values.

Banners

  • Excluded codex from missing API key banner.
  • Added Codex health/fallback warning banner.

Docs

  • Added full guide: docs/guides/codex-subscription.md
  • Updated:
  • README.md
  • docs/README.md
  • docs/setup/installation.md
  • docs/guides/troubleshooting.md
  • Added Codex guide image placeholders in docs/res/setup/codex/.

Tests
Added:

  • tests/test_codex_exec_helper.py
  • tests/test_codex_provider_fallback.py
  • tests/test_settings_codex_prev_snapshot.py
  • tests/test_codex_chat_normalization.py

Executed:

python -m pytest -q \
  tests/test_codex_exec_helper.py \
  tests/test_codex_provider_fallback.py \
  tests/test_settings_codex_prev_snapshot.py \
  tests/test_codex_chat_normalization.py
Result: 15 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

Comments