Skip to content

[BUG] managed_section ignored when compilation.strategy=distributed (default) #1764

@deinsone

Description

@deinsone

Managed-section mode is implemented in PR #1589 but only wired to the legacy single-file write path.

Repro

  1. Set apm.yml:
    compilation:
      agents_md:
        mode: managed_section
  2. Create AGENTS.md with <!-- apm:start --> / <!-- apm:end --> markers plus human-written content outside the markers.
  3. Run apm compile (default strategy: distributed).

Expected: only the block between markers is replaced, hand-written content is preserved.
Actual: the entire AGENTS.md is overwritten.

Root cause

  • agents_compiler.py::_compile_single_file() calls _write_output_file_with_config() (honors managed_section).
  • agents_compiler.py::_compile_distributed() (default strategy since Task 7) writes files via DistributedAgentsCompiler which has no managed-section handling.
  • Even with --single-agents, commands/compile/cli.py takes a dry-run/intermediate path and writes via CompiledOutputWriter().write() directly, bypassing _write_output_file_with_config().

So the helper apply_managed_section() exists and is correct, but the active compile paths don't invoke it.

Suggested fix

Route distributed (and single-file CLI) AGENTS.md writes through _write_output_file_with_config() when the target file is the root AGENTS.md.

Environment

  • apm 0.20.0 (also reproduced in 0.18.0 via devbox)
  • target: opencode

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCLI command surface, flags, help text (cross-cutting).priority/highShips in current or next milestonestatus/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).theme/governanceGoverned by policy. apm-policy, audit, enforcement, enterprise rollout.type/bugSomething does not work as documented.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions