Skip to content

[codex] Add OpenAI Responses fallback for mini models#784

Draft
nyldn wants to merge 1 commit into
safishamsi:v7from
nyldn:codex/openai-codex-fallback
Draft

[codex] Add OpenAI Responses fallback for mini models#784
nyldn wants to merge 1 commit into
safishamsi:v7from
nyldn:codex/openai-codex-fallback

Conversation

@nyldn
Copy link
Copy Markdown
Contributor

@nyldn nyldn commented May 8, 2026

Summary

  • add OpenAI Responses API routing for GPT-5.x / Codex model names when users explicitly select them with --backend openai --model ... or GRAPHIFY_OPENAI_MODEL
  • add opt-in OpenAI model fallback via GRAPHIFY_OPENAI_FALLBACK_MODELS, preserving the existing gpt-4.1-mini default and Chat Completions path
  • document mini-model examples such as gpt-5.5-mini with fallback to gpt-5.4-mini,gpt-4.1-mini

Scope / duplication check

  • This does not change backend detection priority or the existing OpenAI default model.
  • I checked open upstream issues and PRs for openai codex mini fallback gpt-5.5 gpt-5.4; no matching open item came back.

Validation

  • uv run --with pytest pytest tests/test_llm_backends.py tests/test_ollama.py -q -> 18 passed
  • python3 -m compileall graphify/llm.py graphify/__main__.py -> passed
  • uv run graphify --help | sed -n '/extract <path>/,+8p' -> verified help text
  • graphify update . -> completed code graph refresh
  • uv run --with pytest pytest -q -> 667 passed, 6 failed in existing Fortran/SQL parser tests unrelated to this backend change (test_fortran_capital_F_parses_preprocessed, SQL table/view/function/edge assertions)

Copy link
Copy Markdown
Owner

@safishamsi safishamsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues to fix before merging:

1. _call_llm not updated for Responses API routing
extract_files_direct routes GPT-5/codex-mini to _call_openai_responses, but _call_llm (used by the dedup tiebreaker path) still routes everything through _call_openai_compat. GPT-5 users hitting the dedup path will get API errors. _call_llm needs the same if model in RESPONSES_API_MODELS branch.

2. Replace assert last_exc is not None with an explicit raise

# instead of:
assert last_exc is not None
raise last_exc

# use:
if last_exc is None:
    raise RuntimeError("retry loop exited without exception")
raise last_exc

assert is silently removed under python -O, which would cause an UnboundLocalError on last_exc in optimized builds.

Fix these two and CI passes → ready to merge.

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.

2 participants