Add Codex reasoning effort routing#57
Conversation
Co-Authored-By: Codex <noreply@openai.com>
🤖 Codex PR ReviewPlease ensure a human reviewer checks this PR before merging. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58b672ffda
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _resolve_reasoning_effort(payload: dict[str, Any], task: str) -> str: | ||
| requested = _normalize_reasoning_effort(str(payload.get("reasoning_effort") or "")) | ||
| if requested and requested != "auto": | ||
| return requested | ||
|
|
||
| configured = _normalize_reasoning_effort(os.environ.get("CODEX_AUDIT_SERVICE_REASONING_EFFORT", "")) | ||
| if configured and configured != "auto": | ||
| return configured |
There was a problem hiding this comment.
Honor the service override before caller input
When CODEX_AUDIT_SERVICE_REASONING_EFFORT is set to enforce a VPS-wide effort policy, this branch returns a caller-supplied reasoning_effort before checking the configured value, so any authorized request can bypass the documented hard override and force a different Codex effort/cost profile. Check the service env override first and only use payload/complexity routing when it is unset or auto; the same precedence issue exists in service/ai_gateway_service.py.
Useful? React with 👍 / 👎.
| if effort not in CODEX_REASONING_EFFORTS: | ||
| raise ValueError( | ||
| f"reasoning_effort must be one of auto,{','.join(sorted(CODEX_REASONING_EFFORTS))}" | ||
| ) |
There was a problem hiding this comment.
Fail async jobs on invalid reasoning effort
If a request or service env contains an invalid reasoning effort, this ValueError is raised from _run_job_background after the job has already been marked running, but that worker only catches RuntimeError, subprocess errors, and OSError. The thread exits without _update_job(..., "failed"), leaving clients polling a permanently running job and duplicate submissions deduped until cleanup; validate before queuing or catch ValueError in the worker.
Useful? React with 👍 / 👎.
Summary\n- add hard override and task-complexity routing for VPS Codex reasoning effort\n- pass model_reasoning_effort through service adapters and deployment env\n- keep compatibility deployment channel in sync with AIAuditBridge\n\n## Tests\n- python3 -m ruff check scripts/codex_audit_service.py service/ai_gateway_service.py service/adapters/codex_adapter.py tests/test_codex_audit_service_complexity.py\n- python3 -m py_compile scripts/codex_audit_service.py service/ai_gateway_service.py service/adapters/codex_adapter.py\n- bash -n scripts/deploy_codex_audit_service.sh\n- python3 -m unittest discover -s tests -v