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
- Add a script to
apm.yml:
scripts:
fix-issue: "copilot --allow-all-tools --model gpt-5.3-codex -p fix-issue.prompt.md"
- 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
Description
When a script command includes
--model gpt-5.3-codex(or any model name containing the substringcodex), the APM script runner incorrectly transforms thecopilotcommand into acodex execcommand, causing execution to fail withNo such file or directory: 'codex'.Steps to Reproduce
apm.yml:apm run fix-issueResult: APM transforms the command to
codex exec --model gpt-5.3-codex -pand fails: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_commanduses:This regex matches
codexanywhere in the command string — including as a substring of--model gpt-5.3-codex. Sincegpt-5.3-codex --allow-all-tools ... fix-issue.prompt.mdmatchescodex\s+.*fix-issue.prompt.md, the entire command gets rewritten as acodex execinvocation.Suggested Fix
Anchor the match so
codexis only recognized as a standalone word at the start of the runtime binary, not inside a flag value:Workaround
Omit
--modelentirely and let Copilot CLI default to its built-in model selection:Environment