Skip to content

bug: codex init template produces 0% shell-prefix compliance with gpt-5.4-mini #9

Closed

Description

@thehoff

Summary

The contextcrawler init -g --codex command writes a CONTEXTCRAWLER.md whose prefix rule is too weak to influence Codex CLI's actual shell-command choices. Empirical compliance: 0%.

Reproduction (2026-05-18)

  1. contextcrawler init -g --codex (writes ~/.codex/AGENTS.md with @~/.codex/CONTEXTCRAWLER.md reference)
  2. Fresh process: codex exec --skip-git-repo-check --sandbox read-only 'Show me the recent commit history (last 3 commits, one-line format). Then briefly list what files were modified in the most recent commit.'
  3. Observe shell calls Codex actually issues.

Result

Codex ran:

  • /bin/zsh -lc 'git log -3 --oneline' ← raw, no contextcrawler prefix
  • /bin/zsh -lc 'git show --name-only ...' ← raw, no contextcrawler prefix

Token savings: 0.

Verification it reads the file

A direct prompt — Quote verbatim the rule about shell command prefixes — returned the expected line, confirming the template is loaded. The model knows the rule and chooses not to apply it.

Root cause

hooks/codex/rtk-awareness.md (compiled in as RTK_SLIM_CODEX at src/hooks/init.rs:25) uses single-line advisory wording:

Always prefix shell commands with contextcrawler.

This loses against Codex's own use shell tool system-prompt guidance. gpt-5.4-mini in particular treats it as soft advice and reaches for the obvious shell form.

Fix (proposed)

Strengthen hooks/codex/rtk-awareness.md with:

  • Imperative MUST wording at top
  • Concrete WRONG / RIGHT examples covering common commands
  • Explicit applies-to command list
  • Self-check instruction (before issuing any shell call, check: does it start with contextcrawler ?)

Empirical validation of the fix

Inlined the strengthened block at the top of ~/.codex/AGENTS.md (not the @-import) and re-ran the same prompt. Compliance: 100% (both shell calls now prefixed with contextcrawler). contextcrawler gain --history shows 80%+ savings on the git-log filter.

Scope

  • Edit hooks/codex/rtk-awareness.md (the embedded template)
  • Update snapshot/exact-match test at src/hooks/init.rs:3191 (assert_eq!(fs::read_to_string(&rtk_md).unwrap(), RTK_SLIM_CODEX))
  • No logic changes, no new dependencies

Out of scope (deferred follow-up)

If salience-via-@-import remains the bottleneck under heavier prompts, escalate by inlining a short rule block directly into AGENTS.md (in addition to CONTEXTCRAWLER.md). Requires logic change in run_codex_mode_with_paths() and a separate idempotent block-management path. Not needed yet — the template strengthening alone got 100% on the test case.

Test plan

  • cargo test --all passes (snapshot/exact-match assertion updated)
  • Reinstall binary, run codex exec with the same git-log prompt, confirm contextcrawler prefix appears in the shell trace
  • contextcrawler gain --history shows the savings entry
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions