Skip to content

fix(gateway): pass model to temporary AIAgent instances#830

Open
manuelschipper wants to merge 1 commit intoNousResearch:mainfrom
manuelschipper:fix/gateway-model-for-codex
Open

fix(gateway): pass model to temporary AIAgent instances#830
manuelschipper wants to merge 1 commit intoNousResearch:mainfrom
manuelschipper:fix/gateway-model-for-codex

Conversation

@manuelschipper
Copy link

@manuelschipper manuelschipper commented Mar 10, 2026

Summary

  • Memory flush (_flush_memories_for_session), session hygiene auto-compressor, and /compress command create temporary AIAgent instances without passing model=, so they fall back to the hardcoded default "anthropic/claude-opus-4.6"
  • This fails with a 400 error when the active provider is openai-codex (Codex only accepts its own model names like gpt-5.1-codex-mini)
  • Added _resolve_gateway_model() helper that mirrors the env/config resolution already used by _run_agent_sync and the cron scheduler
  • Wired it into all three temporary agent creation sites (session hygiene already had the model resolved into _hyg_model but never passed it to the constructor)

Error reproduced

Error code: 400 - {'detail': "The 'anthropic/claude-opus-4.6' model is not supported when using Codex with a ChatGPT account."}

Triggered during pre-reset memory flush when provider: openai-codex is configured in config.yaml.

Test plan

  • All 473 gateway tests pass
  • Full suite: 2755 passed (1 pre-existing flaky in test_vision_tools, see fix/vision-test-flake branch)
  • End-to-end: memory flush on real Pili session via Codex provider — completed successfully, zero errors
  • Live Telegram: sent messages + /reset to Pili bot — flush completed, no new errors in log

Memory flush, /compress, and session hygiene create AIAgent without
model=, falling back to the hardcoded default "anthropic/claude-opus-4.6".
This fails with a 400 error when the active provider is openai-codex
(Codex only accepts its own model names like gpt-5.1-codex-mini).

Add _resolve_gateway_model() that mirrors the env/config resolution
already used by _run_agent_sync, and wire it into all three temporary
agent creation sites.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@manuelschipper manuelschipper force-pushed the fix/gateway-model-for-codex branch from d631da7 to e2d2e9f Compare March 10, 2026 23:09
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