Skip to content

[FEATURE] Extend opt-in source attribution to AGENTS.md (#1341 follow-up: distributed compiler still hardcodes version comment and footer) #2634

Closed

Description

@Ives7

Is your feature request related to a problem? Please describe.

#1341 asked to make the cosmetic compile comments opt-in in generated CLAUDE.md and AGENTS.md. The implementing PR #1584 flipped compilation.source_attribution to default false and gated those comments in claude_formatter.py (plus copilot-instructions.md), but the distributed AGENTS.md path was never covered.

On v0.28.0 the APM Version comment and the trailing footer are still emitted unconditionally there, so projects compiling for AGENTS.md-reading targets (codex, opencode, gemini, ...) keep paying that token cost in every session with no way to opt out.

Reproduced on apm 0.28.0 (e041462):

# apm.yml
name: bannertest
version: 1.0.0
targets:
  - codex
compilation:
  source_attribution: false   # also the default since #1584
$ apm compile --target codex
$ cat AGENTS.md
# AGENTS.md
<!-- Generated by APM CLI from distributed .apm/ primitives -->
<!-- Build ID: f4429da3a4a0 -->
<!-- APM Version: 0.28.0 -->

## Files matching `**`

Demo rule body.

---
*This file was generated by APM CLI. Do not edit manually.*
*To regenerate: `apm compile`*

The same project compiled with --target claude honours the default correctly and emits only the load-bearing lines:

$ apm compile --target claude
$ cat CLAUDE.md
# CLAUDE.md
<!-- Generated by APM CLI -->
<!-- Build ID: 9c31e7202c55 -->

## Project Standards
...

Describe the solution you'd like

Gate the two cosmetic blocks in DistributedAgentsCompiler._generate_agents_content on source_attribution, exactly as the Claude path already does:

  • src/apm_cli/compilation/distributed_compiler.py:655 -- <!-- APM Version: ... -->
  • src/apm_cli/compilation/distributed_compiler.py:680-682 -- the --- / *This file was generated by APM CLI. Do not edit manually.* / *To regenerate: apm compile* footer

Reference implementation: src/apm_cli/compilation/claude_formatter.py:299-300 and :338-343.

The flag value already reaches this code path, so the change looks self-contained: agents_compiler.py:571 passes source_attribution into distributed_config, and distributed_compiler.py:180 reads it into placement.source_attribution, where it currently only drives the <!-- Sources: --> line and the per-instruction source comments.

Load-bearing lines that should stay unconditional

Mirroring the Claude path, these two should keep being emitted regardless of the flag:

  • AGENTS_MD_GENERATED_MARKER (distributed_compiler.py:653) -- _find_orphaned_agents_files only ever deletes files bearing it (_file_has_apm_marker, distributed_compiler.py:783-796), so dropping it would make apm compile --clean silently stop cleaning orphaned AGENTS.md.
  • BUILD_ID_PLACEHOLDER (distributed_compiler.py:654) -- normalized away by drift detection (utils/normalization.py:22).

Describe alternatives you've considered

  • Setting compilation.source_attribution: false in apm.yml -- verified to have no effect on this path (it is already the default).
  • No CLI flag, apm config key, or environment variable covers it; apm compile --help on 0.28.0 exposes nothing equivalent.
  • Post-processing AGENTS.md after compile -- clobbered by the next apm compile (verified), and stripping the header marker breaks --clean as described above.

Additional context

apm 0.28.0 (e041462), macOS arm64. All line numbers above are against tag v0.28.0.

Activity

  1. github-actions commented on Aug 20, 2026

    @github-actions

    Triage Verdict -- #2634: [FEATURE] Extend opt-in source attribution to AGENTS.md

    Panel Summary

    DevX UX Expert: This is a correctness bug masquerading as a feature request: source_attribution: false is explicitly documented as the way to suppress cosmetic token-consuming comments, it works on every target except AGENTS.md targets (codex, opencode, gemini), and the user has no workaround. Developers targeting agent runtimes with tight context windows are being penalized unconditionally. The asymmetry between Claude output and AGENTS.md output for the same apm.yml flag value is a user trust violation -- the config says false and the behavior is true.

    Supply Chain Security Expert: No security surface. The AGENTS_MD_GENERATED_MARKER and BUILD_ID_PLACEHOLDER must remain unconditional (the issue author correctly identifies this) because orphan detection and drift detection are coupled to their presence. Gating only the cosmetic version comment and the human-readable footer is safe.

    Python Architect: The fix is precisely scoped: in DistributedAgentsCompiler._generate_agents_content, wrap the <!-- APM Version: ... --> line and the --- / *This file was generated...* / *To regenerate...* footer block in if placement.source_attribution: guards. The source_attribution value is already plumbed through to placement.source_attribution -- this is purely a missing guard, no plumbing change needed. Reference implementation: claude_formatter.py:299-300 and :338-343.

    Doc Writer: The compilation.source_attribution docs should note that suppression applies to all compile targets including AGENTS.md targets once fixed; a one-line addendum to the compilation reference page suffices.

    APM CEO (Arbiter): ACCEPT. This is a confirmed bug -- a parity gap introduced when #1584 implemented #1341 for the Claude path but left the distributed AGENTS.md path uncovered. The reporter has done the full root-cause analysis, identified the exact lines to change, confirmed which lines must remain unconditional, and verified on v0.28.0. The fix is a ~5-line guarded block. The flag already exists, the user explicitly set it, and it is silently ignored on a documented code path. This should land as a bug fix in the next patch.


    Decision

    Verdict: ACCEPT
    Type: type/bug
    Area(s): area/cli, area/distribution
    Theme(s): none
    Priority: priority/high
    Milestone: none at this time
    Next action: Wrap the <!-- APM Version: ... --> comment and the trailing --- / generated-by footer in _generate_agents_content inside if placement.source_attribution: guards, mirroring claude_formatter.py:299-300 and :338-343, and add a test asserting that source_attribution: false suppresses both blocks across all non-Claude compile targets.


    Triage status: agentic proposal pending human ratification.
    Silence is approval. Maintainers can:

    • Override any label or milestone above by editing it directly --
      human edits are authoritative and will not be reverted on
      subsequent runs.
    • Re-trigger triage by applying the status/needs-triage label, or
      by removing status/triaged to enroll the issue in the next
      daily sweep.

    Posted by the Triage Panel workflow. See .apm/skills/apm-triage-panel for the panel skill.

    Generated by Triage Panel · 103.3 AIC · ⌖ 6.6 AIC · ⊞ 9.2K · ◷

  2. added
    area/cli
    area/distribution
    priority/high
    status/accepted
    status/triaged
    type/bug
    on Aug 20, 2026
  3. moved this from Todo to In Progress in APM Roadmapon Aug 21, 2026
  4. moved this from In Progress to Done in APM Roadmapon Aug 23, 2026
  5. added a commit that references this issue on Aug 23, 2026
    effcbd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliarea/distributionpriority/highstatus/acceptedstatus/triagedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions