Skip to content

Bug: script runner misidentifies 'codex' in model names as the codex runtime binary #396

@ryan-niemes-helix

Description

@ryan-niemes-helix

Description

When a script command includes --model gpt-5.3-codex (or any model name containing the substring codex), the APM script runner incorrectly transforms the copilot command into a codex exec command, causing execution to fail with No such file or directory: 'codex'.

Steps to Reproduce

  1. Add a script to apm.yml:
    scripts:
      fix-issue: "copilot --allow-all-tools --model gpt-5.3-codex -p fix-issue.prompt.md"
  2. Run: apm run fix-issue

Result: APM transforms the command to codex exec --model gpt-5.3-codex -p and fails:

Script execution error: [Errno 2] No such file or directory: 'codex'

Expected: APM runs copilot --allow-all-tools --model gpt-5.3-codex -p <content>

Root Cause

In src/apm_cli/core/script_runner.py, _transform_runtime_command uses:

if re.search(r"codex\s+.*" + re.escape(prompt_file), command):

This regex matches codex anywhere in the command string — including as a substring of --model gpt-5.3-codex. Since gpt-5.3-codex --allow-all-tools ... fix-issue.prompt.md matches codex\s+.*fix-issue.prompt.md, the entire command gets rewritten as a codex exec invocation.

Suggested Fix

Anchor the match so codex is only recognized as a standalone word at the start of the runtime binary, not inside a flag value:

if re.search(r"(^|\s)codex\s+.*" + re.escape(prompt_file), command):

Workaround

Omit --model entirely and let Copilot CLI default to its built-in model selection:

scripts:
  fix-issue: "copilot --allow-all-tools -p fix-issue.prompt.md"

Environment

  • APM version: 0.8.3
  • Platform: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions