Skip to content

feat: respect CODEX_DEFAULT_MODEL env var in tool descriptions#125

Open
MrYoqaq wants to merge 1 commit intotuannvm:mainfrom
MrYoqaq:fix/env-model-description
Open

feat: respect CODEX_DEFAULT_MODEL env var in tool descriptions#125
MrYoqaq wants to merge 1 commit intotuannvm:mainfrom
MrYoqaq:fix/env-model-description

Conversation

@MrYoqaq
Copy link

@MrYoqaq MrYoqaq commented Mar 10, 2026

Problem

When using this MCP server with AI agents (like Claude), the agent sees the hardcoded model list in tool descriptions:

Specify which model to use (defaults to gpt-5.3-codex). Options: gpt-5.3-codex, gpt-5.2-codex, ...

This causes issues because:

  1. The model list becomes outdated as OpenAI releases new models
  2. AI agents may try to use outdated model names from this list
  3. Even with CODEX_DEFAULT_MODEL env var set, the description still shows the old list

Solution

When CODEX_DEFAULT_MODEL environment variable is set:

  • Use the env var value as default model in tool descriptions
  • Hide the hardcoded model list (which may become outdated)

This way, users who set CODEX_DEFAULT_MODEL get clean descriptions without outdated model names.

Changes

  • Modified getModelDescription() in src/types.ts to read the env var
  • Backward compatible: original behavior preserved when env var is not set

Summary by CodeRabbit

  • Refactoring
    • Model selection descriptions now support environment-based configuration. When enabled, descriptions provide simplified guidance for model selection. When not configured, comprehensive model listings display as before, ensuring full backward compatibility with existing setups.

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.
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Walkthrough

The getModelDescription function in src/types.ts has been enhanced to support environment-variable configuration. When CODEX_DEFAULT_MODEL_ENV_VAR is set, it returns simplified descriptions with the environmentally-determined default model; otherwise, it retains the original behavior with full model listings.

Changes

Cohort / File(s) Summary
Environment-aware model description
src/types.ts
Modified getModelDescription to conditionally check for CODEX_DEFAULT_MODEL_ENV_VAR; returns simplified prompts when the variable is set, otherwise provides original behavior with full AVAILABLE_CODEX_MODELS listing.

Possibly related PRs

Poem

🐰 A model description now bends to the breeze,
Checking the winds (environment, please!),
Simplified paths when the variable's set,
Full lists when it's not—no regrets yet! 🌬️✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: respecting the CODEX_DEFAULT_MODEL environment variable in tool descriptions, which aligns perfectly with the core objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 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_MODEL policy that already exists in src/tools/handlers.ts for 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d0d0f63-796b-4611-9dd2-fe80aefbdb7a

📥 Commits

Reviewing files that changed from the base of the PR and between 00b6bf6 and a6892ab.

📒 Files selected for processing (1)
  • src/types.ts

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