rulesync icon indicating copy to clipboard operation
rulesync copied to clipboard

codexcli rules: glob-scoped rules are inlined into `AGENTS.md`; output over 32 KiB is silently truncated by Codex

Open artgas1 opened this issue 2 months ago • 0 comments

Summary

For codexcli, rulesync concatenates every rule into the root AGENTS.md, including rules scoped by paths/globs. Nothing warns about the size of the result. Codex reads at most project_doc_max_bytes of project instructions, 32 KiB by default (AGENTS.md guide), and silently drops the rest. The scoping is also lost: rules meant for services/svcN/** become always-on for the part that fits.

Reproduction (rulesync 21.0.0, Codex CLI 0.153.1)

A small CLAUDE.md plus six rules like this one in .claude/rules/svcN.md, about 8 KB each:

---
paths:
  - "services/svc1/**"
---

# Rule for svc1
...
rulesync import --targets claudecode --features rules
rulesync generate --targets codexcli --features rules
codex debug prompt-input "probe"   # renders the model-visible input without calling the model

Actual

  • The generated AGENTS.md is 50,538 bytes. All six rules are inlined, and the paths scoping doesn't appear anywhere.
  • codex debug prompt-input shows that exactly the first 32,768 bytes reach the model. # Rule for svc5 and # Rule for svc6 are missing entirely.
  • rulesync printed no warning.

On a real configuration with 29 rules, the generated AGENTS.md was 854 KB, and only 4.6% of it reached the model.

Suggestion

  • Warn when the generated AGENTS.md exceeds 32 KiB, or the configured limit once #2496 lands, since that issue covers the missing authoring path for project_doc_max_bytes.
  • Don't inline glob-scoped rules. Possible options:
    • write them as separate files and list them in AGENTS.md with their globs ("read X when working on files matching Y");
    • when a glob is a plain directory prefix, emit a nested AGENTS.md, which is what the Codex docs recommend for large instruction sets.

artgas1 avatar Sep 26 '26 12:09 artgas1