update codex skills model config

This commit is contained in:
cexll
2025-11-19 23:57:52 +08:00
parent 3f7652f992
commit bbd2f50c38
2 changed files with 19 additions and 25 deletions

View File

@@ -14,33 +14,29 @@ Execute Codex CLI commands and parse structured JSON responses. Supports file re
- Complex code analysis requiring deep understanding - Complex code analysis requiring deep understanding
- Large-scale refactoring across multiple files - Large-scale refactoring across multiple files
- Automated code generation with safety controls - Automated code generation with safety controls
- Tasks requiring specialized reasoning models (gpt-5.1, gpt-5.1-codex)
## Usage ## Usage
**Mandatory**: Run every automated invocation through the Bash tool in the foreground with the command below, keeping the `timeout` parameter fixed at `7200000` milliseconds (do not change it or use any other entry point). **Mandatory**: Run every automated invocation through the Bash tool in the foreground with the command below, keeping the `timeout` parameter fixed at `7200000` milliseconds (do not change it or use any other entry point).
```bash ```bash
uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
``` ```
**Foreground only (no background/BashOutput)**: Never set `background: true`, never accept Claude's “Running in the background” mode, and avoid `BashOutput` streaming loops. Keep a single foreground Bash call per Codex task; if work might be long, split it into smaller foreground runs instead of offloading to background execution. **Foreground only (no background/BashOutput)**: Never set `background: true`, never accept Claude's “Running in the background” mode, and avoid `BashOutput` streaming loops. Keep a single foreground Bash call per Codex task; if work might be long, split it into smaller foreground runs instead of offloading to background execution.
**Optional methods** (direct execution or via Python): **Optional methods** (direct execution or via Python):
```bash ```bash
~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
# or # or
python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
``` ```
Resume a session: Resume a session:
```bash ```bash
uv run ~/.claude/skills/codex/scripts/codex.py resume <session_id> "<task>" [model] [working_dir] uv run ~/.claude/skills/codex/scripts/codex.py resume <session_id> "<task>" [working_dir]
``` ```
## Environment Variables ## Environment Variables
- **CODEX_MODEL**: Override default model (default: `gpt-5.1-codex`)
- Example: `export CODEX_MODEL=gpt-5-codex`
- **CODEX_TIMEOUT**: Override timeout in milliseconds (default: 7200000 = 2 hours) - **CODEX_TIMEOUT**: Override timeout in milliseconds (default: 7200000 = 2 hours)
- Example: `export CODEX_TIMEOUT=3600000` for 1 hour - Example: `export CODEX_TIMEOUT=3600000` for 1 hour
@@ -55,9 +51,6 @@ uv run ~/.claude/skills/codex/scripts/codex.py resume <session_id> "<task>" [mod
### Parameters ### Parameters
- `task` (required): Task description, supports `@file` references - `task` (required): Task description, supports `@file` references
- `model` (optional): Model to use (default: gpt-5.1-codex)
- `gpt-5.1-codex`: Default, optimized for code
- `gpt-5.1`: Fast general purpose
- `working_dir` (optional): Working directory (default: current) - `working_dir` (optional): Working directory (default: current)
### Return Format ### Return Format
@@ -82,7 +75,7 @@ Return only the final agent message and session ID—do not paste raw `BashOutpu
All automated executions may only invoke `uv run ~/.claude/skills/codex/scripts/codex.py "<task>" ...` through the Bash tool in the foreground, and the `timeout` must remain fixed at `7200000` (non-negotiable): All automated executions may only invoke `uv run ~/.claude/skills/codex/scripts/codex.py "<task>" ...` through the Bash tool in the foreground, and the `timeout` must remain fixed at `7200000` (non-negotiable):
``` ```
Bash tool parameters: Bash tool parameters:
- command: uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] - command: uv run ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
- timeout: 7200000 - timeout: 7200000
- description: <brief description of the task> - description: <brief description of the task>
``` ```
@@ -91,10 +84,10 @@ Run every call in the foreground—never append `&` to background it—so logs a
Alternatives: Alternatives:
``` ```
# Direct execution (simplest) # Direct execution (simplest)
- command: ~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] - command: ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
# Using python3 # Using python3
- command: python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [model] [working_dir] - command: python3 ~/.claude/skills/codex/scripts/codex.py "<task>" [working_dir]
``` ```
### Examples ### Examples
@@ -109,22 +102,23 @@ uv run ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts"
~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts" ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts"
``` ```
**Refactoring with specific model:** **Refactoring with custom model (via environment variable):**
```bash ```bash
uv run ~/.claude/skills/codex/scripts/codex.py "refactor @src/utils for performance" "gpt-5.1-codex" # Set model via environment variable
uv run ~/.claude/skills/codex/scripts/codex.py "refactor @src/utils for performance"
# timeout: 7200000 # timeout: 7200000
``` ```
**Multi-file analysis:** **Multi-file analysis:**
```bash ```bash
uv run ~/.claude/skills/codex/scripts/codex.py "analyze @. and find security issues" "gpt-5.1-codex" "/path/to/project" uv run ~/.claude/skills/codex/scripts/codex.py "analyze @. and find security issues" "/path/to/project"
# timeout: 7200000 # timeout: 7200000
``` ```
**Resume previous session:** **Resume previous session:**
```bash ```bash
# First session # First session
uv run ~/.claude/skills/codex/scripts/codex.py "add comments to @utils.js" "gpt-5.1-codex" uv run ~/.claude/skills/codex/scripts/codex.py "add comments to @utils.js"
# Output includes: SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14 # Output includes: SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14
# Continue the conversation # Continue the conversation

View File

@@ -8,10 +8,12 @@ Codex CLI wrapper with cross-platform support and session management.
**FIXED**: Auto-detect long inputs and use stdin mode to avoid shell argument issues. **FIXED**: Auto-detect long inputs and use stdin mode to avoid shell argument issues.
Usage: Usage:
New session: uv run codex.py "task" [model] [workdir] New session: uv run codex.py "task" [workdir]
Resume: uv run codex.py resume <session_id> "task" [model] [workdir] Resume: uv run codex.py resume <session_id> "task" [workdir]
Alternative: python3 codex.py "task" Alternative: python3 codex.py "task"
Direct exec: ./codex.py "task" Direct exec: ./codex.py "task"
Model configuration: Set CODEX_MODEL environment variable (default: gpt-5.1-codex)
""" """
import subprocess import subprocess
import json import json
@@ -82,15 +84,13 @@ def parse_args():
'mode': 'resume', 'mode': 'resume',
'session_id': sys.argv[2], 'session_id': sys.argv[2],
'task': sys.argv[3], 'task': sys.argv[3],
'model': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_MODEL, 'workdir': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_WORKDIR
'workdir': sys.argv[5] if len(sys.argv) > 5 else DEFAULT_WORKDIR
} }
else: else:
return { return {
'mode': 'new', 'mode': 'new',
'task': sys.argv[1], 'task': sys.argv[1],
'model': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_MODEL, 'workdir': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_WORKDIR
'workdir': sys.argv[3] if len(sys.argv) > 3 else DEFAULT_WORKDIR
} }
@@ -146,7 +146,7 @@ def build_codex_args(params: dict, target_arg: str) -> list:
else: else:
base_args = [ base_args = [
'codex', 'e', 'codex', 'e',
'-m', params['model'], '-m', DEFAULT_MODEL,
'--dangerously-bypass-approvals-and-sandbox', '--dangerously-bypass-approvals-and-sandbox',
'--skip-git-repo-check', '--skip-git-repo-check',
'-C', params['workdir'], '-C', params['workdir'],