Skip to content

Add support for model_reasoning_effort parameter to control thinking budget #37

@SaladDay

Description

@SaladDay

Problem

Currently, the codex MCP tool only supports specifying the model parameter, but doesn't allow controlling the model_reasoning_effort configuration. This means all tasks use the same thinking budget defined in ~/.codex/config.toml, which is suboptimal for different task complexities.

Use Case

Different tasks require different levels of reasoning:

  • Simple tasks (e.g., "add a print statement", "fix typo"): low or medium reasoning effort is sufficient and faster
  • Complex tasks (e.g., "refactor architecture", "debug race condition"): high or xhigh reasoning effort provides better quality

Currently, users must either:

  1. Manually edit ~/.codex/config.toml before each task (cumbersome)
  2. Create multiple profiles (requires pre-configuration and doesn't scale)
  3. Accept suboptimal performance (waste time on simple tasks or get poor results on complex ones)

Proposed Solution

Add a reasoning_effort parameter to the codex tool that maps to Codex CLI's -c model_reasoning_effort="..." option:

@mcp.tool()
async def codex(
    PROMPT: Annotated[str, "Task instruction"],
    cd: Annotated[Path, "Workspace root directory"],
    # ... existing parameters ...
    reasoning_effort: Annotated[
        Optional[str], 
        "Reasoning effort level: 'low', 'medium', 'high', 'xhigh'. Controls thinking budget for the task."
    ] = None,
) -> dict:
    # ...
    if reasoning_effort:
        cmd.extend(["-c", f'model_reasoning_effort="{reasoning_effort}"'])

Example Usage

# Quick fix - use low reasoning
mcp.call_tool("codex", {
    "PROMPT": "Add error logging to line 42",
    "cd": "/path/to/project",
    "reasoning_effort": "low"
})

# Complex refactoring - use xhigh reasoning
mcp.call_tool("codex", {
    "PROMPT": "Refactor the authentication system to support OAuth2",
    "cd": "/path/to/project", 
    "reasoning_effort": "xhigh"
})

Benefits

  1. Performance: Faster responses for simple tasks
  2. Quality: Better results for complex tasks
  3. Cost efficiency: Avoid unnecessary compute on trivial operations
  4. Flexibility: Claude Code can dynamically adjust reasoning budget based on task complexity

Additional Context

The Codex CLI already supports this via -c model_reasoning_effort="...". This feature request simply exposes that capability through the MCP interface, similar to how the model parameter is already exposed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions