Describe the bug
apm compile --target codex appears to be broken in the distributed Codex compile path.
In my real project, AGENTS.md already exists, but one dependency instruction is missing after Codex-targeted distributed compile. The missing content is from codex-sync.instructions.md, while another dependency instruction from forgebridge.instructions.md remains present.
After tracing the behavior, this looks less like partial instruction merging and more like a silent no-op:
apm compile --target codex exits successfully
- the existing
AGENTS.md is not rewritten at all
- because the stale file remains in place, it looks like Codex distributed compile generated an incomplete result
This reproduces on both:
- PyPI
apm-cli 0.8.11
- latest
main source at 522c24690ea2f42aea5a2d80441c742f0a67d607
This initially looked similar to #631 / #642 because validate can see both instructions while normal compile appears to drop one. However, this repro still fails even when the instructions are already local, so it does not look like the dependency .github/ scan bug fixed by #642.
To Reproduce
Steps to reproduce the behavior:
-
Create a minimal project with this layout:
codex-compile-repro/
├─ apm.yml
└─ packages/
├─ pkg-a/
│ ├─ apm.yml
│ └─ .apm/instructions/a.instructions.md
└─ pkg-b/
├─ apm.yml
└─ .apm/instructions/b.instructions.md
-
Use this root apm.yml:
name: codex-compile-repro
version: 1.0.0
dependencies:
apm:
- ./packages/pkg-a
- ./packages/pkg-b
mcp: []
scripts: {}
-
Put one simple instruction in each package:
---
applyTo: "**"
---
# Package A
- Rule from package A.
---
applyTo: "**"
---
# Package B
- Rule from package B.
-
Run:
apm install
apm compile --validate -v
apm compile --target codex --dry-run -v
apm compile --target codex
-
Observe that:
apm compile --validate -v reports 2 instructions
apm compile --target codex --dry-run -v only prints startup/progress lines and no AGENTS preview
apm compile --target codex exits successfully but does not create AGENTS.md in the minimal repro
-
In a real project where AGENTS.md already exists, observe that:
- the file hash and modified timestamp remain unchanged after
apm compile --target codex
- the stale
AGENTS.md remains in place, which makes it look like one dependency instruction was skipped
Expected behavior
apm compile --target codex should generate or update AGENTS.md, because Codex reads instructions from AGENTS.md
- distributed Codex compile should not exit successfully while doing nothing
- if
AGENTS.md already exists, it should be updated when the compiled instruction set changes
Environment (please complete the following information):
- OS: Windows
- Python Version: 3.14.3
- APM Version: 0.8.11
- VSCode Version (if relevant): N/A
Also reproduced against latest main source:
- commit:
522c24690ea2f42aea5a2d80441c742f0a67d607
Logs
apm compile --validate -v
[*] Validating APM context...
[*] All primitives validated successfully!
[i] Validated 2 primitives:
[i] * 0 chatmodes
[i] * 2 instructions
[i] * 0 contexts
apm compile --target codex --dry-run -v
[*] Starting context compilation...
[i] Compiling for AGENTS.md + CLAUDE.md - explicit --target flag
[i] [dry-run] showing placement without writing files
Verbose mode: showing source attribution and optimizer analysis
apm compile --target codex
[*] Starting context compilation...
[i] Compiling for AGENTS.md + CLAUDE.md - explicit --target flag
[+] Compilation completed successfully!
In my real project, the file was not updated:
before_hash=C7B6112B6523F85FF47A8C4C95AEC3F598E505B5A4263F4D9B01BA1CED59F32A
after_hash=C7B6112B6523F85FF47A8C4C95AEC3F598E505B5A4263F4D9B01BA1CED59F32A
before_time=2026-04-19T10:32:54.4094263Z
after_time=2026-04-19T10:32:54.4094263Z
Additional context
Tracing the source locally suggests target-routing drift.
detect_target() correctly returns codex
- the compile CLI passes
target="codex" into CompilationConfig
- but
AgentsCompiler.compile() only routes AGENTS compilation for ("vscode", "agents", "all")
codex never reaches _compile_agents_md()
_merge_results([]) returns a successful empty result, which explains the silent no-op
There is also a misleading progress message:
--target codex reports Compiling for AGENTS.md + CLAUDE.md
- but no AGENTS compile branch actually runs for
codex
Related:
Describe the bug
apm compile --target codexappears to be broken in the distributed Codex compile path.In my real project,
AGENTS.mdalready exists, but one dependency instruction is missing after Codex-targeted distributed compile. The missing content is fromcodex-sync.instructions.md, while another dependency instruction fromforgebridge.instructions.mdremains present.After tracing the behavior, this looks less like partial instruction merging and more like a silent no-op:
apm compile --target codexexits successfullyAGENTS.mdis not rewritten at allThis reproduces on both:
apm-cli 0.8.11mainsource at522c24690ea2f42aea5a2d80441c742f0a67d607This initially looked similar to #631 / #642 because
validatecan see both instructions while normal compile appears to drop one. However, this repro still fails even when the instructions are already local, so it does not look like the dependency.github/scan bug fixed by #642.To Reproduce
Steps to reproduce the behavior:
Create a minimal project with this layout:
Use this root
apm.yml:Put one simple instruction in each package:
Run:
Observe that:
apm compile --validate -vreports 2 instructionsapm compile --target codex --dry-run -vonly prints startup/progress lines and no AGENTS previewapm compile --target codexexits successfully but does not createAGENTS.mdin the minimal reproIn a real project where
AGENTS.mdalready exists, observe that:apm compile --target codexAGENTS.mdremains in place, which makes it look like one dependency instruction was skippedExpected behavior
apm compile --target codexshould generate or updateAGENTS.md, because Codex reads instructions fromAGENTS.mdAGENTS.mdalready exists, it should be updated when the compiled instruction set changesEnvironment (please complete the following information):
Also reproduced against latest
mainsource:522c24690ea2f42aea5a2d80441c742f0a67d607Logs
apm compile --validate -vapm compile --target codex --dry-run -vapm compile --target codexIn my real project, the file was not updated:
Additional context
Tracing the source locally suggests target-routing drift.
detect_target()correctly returnscodextarget="codex"intoCompilationConfigAgentsCompiler.compile()only routes AGENTS compilation for("vscode", "agents", "all")codexnever reaches_compile_agents_md()_merge_results([])returns a successful empty result, which explains the silent no-opThere is also a misleading progress message:
--target codexreportsCompiling for AGENTS.md + CLAUDE.mdcodexRelated: