feat: respect CODEX_DEFAULT_MODEL env var in tool descriptions#125
feat: respect CODEX_DEFAULT_MODEL env var in tool descriptions#125MrYoqaq wants to merge 1 commit intotuannvm:mainfrom
Conversation
When CODEX_DEFAULT_MODEL environment variable is set: - Use the env var value as default model in tool descriptions - Hide hardcoded model list (which may become outdated) This helps AI agents avoid using outdated model names from the hardcoded AVAILABLE_CODEX_MODELS list.
WalkthroughThe Changes
Possibly related PRs
Poem
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/types.ts (1)
34-45: Centralize the default-model lookup.This now duplicates the same
process.env[CODEX_DEFAULT_MODEL_ENV_VAR] || DEFAULT_CODEX_MODELpolicy that already exists insrc/tools/handlers.tsfor execution. Pulling that into a shared helper would reduce drift between what the tool advertises and what it actually runs.♻️ Proposed refactor
+export const getConfiguredDefaultModel = () => + process.env[CODEX_DEFAULT_MODEL_ENV_VAR] || DEFAULT_CODEX_MODEL; + export const getModelDescription = (toolType: 'codex' | 'review') => { - const envModel = process.env[CODEX_DEFAULT_MODEL_ENV_VAR]; - const defaultModel = envModel || DEFAULT_CODEX_MODEL; + const envModel = process.env[CODEX_DEFAULT_MODEL_ENV_VAR]; + const defaultModel = getConfiguredDefaultModel();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/types.ts` around lines 34 - 45, The code duplicates the default-model lookup logic (process.env[CODEX_DEFAULT_MODEL_ENV_VAR] || DEFAULT_CODEX_MODEL) using local variables envModel/defaultModel; extract that logic into a shared helper (e.g., getDefaultModel or resolveDefaultModel) and replace the inline logic in src/types.ts (where envModel/defaultModel are used and messages built) and the corresponding use in handlers.ts so both call the helper; ensure the helper exports the resolved value or a function that returns the default model and update the message construction in the block that currently references defaultModel to call the helper instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/types.ts`:
- Around line 34-45: The code duplicates the default-model lookup logic
(process.env[CODEX_DEFAULT_MODEL_ENV_VAR] || DEFAULT_CODEX_MODEL) using local
variables envModel/defaultModel; extract that logic into a shared helper (e.g.,
getDefaultModel or resolveDefaultModel) and replace the inline logic in
src/types.ts (where envModel/defaultModel are used and messages built) and the
corresponding use in handlers.ts so both call the helper; ensure the helper
exports the resolved value or a function that returns the default model and
update the message construction in the block that currently references
defaultModel to call the helper instead.
Problem
When using this MCP server with AI agents (like Claude), the agent sees the hardcoded model list in tool descriptions:
This causes issues because:
CODEX_DEFAULT_MODELenv var set, the description still shows the old listSolution
When
CODEX_DEFAULT_MODELenvironment variable is set:This way, users who set
CODEX_DEFAULT_MODELget clean descriptions without outdated model names.Changes
getModelDescription()insrc/types.tsto read the env varSummary by CodeRabbit