fix: PreCompact hook degradation, model:inherit passthrough, AGENTS.md hook section formatting - #9
Conversation
…erit, clean AGENTS.md hook section
Found while converting the llmdoc plugin surface:
- PreCompact hooks were dropped entirely with a skip warning; for platforms
where hooks already degrade to AGENTS.md notes (codex/opencode) there is
no reason to treat PreCompact worse than SessionStart/Stop. Degraded
notes now also use event-appropriate timing phrases ('Right before
context compaction, run …' instead of the semantically wrong 'Run after
PreCompact').
- 'model: inherit' (and an absent model) was hardcoded to a mapped model
name (e.g. gpt-5.6-sol), freezing today's default into the output. All
four platform branches now omit the model field so the target platform's
own session default applies.
- A freshly created AGENTS.md opened with a stray '---' (reads as a
frontmatter fence); the hook section is now assembled without a leading
separator, and appending to an existing AGENTS.md trims before adding
the thematic break.
|
Pushed a follow-up that supersedes the codex half of the original approach: Codex plugins support native hooks — default file So for codex, End-to-end on the llmdoc surface: all three hook events land in |
Three conversion gaps found while converting the llmdoc V3 plugin surface to Codex (context: TokenRollAI/llmdoc#32).
1. PreCompact hooks were dropped entirely
PORTABLE_EVENTSdidn't includePreCompact, so it was skipped with a warning — even for codex/opencode where hooks already degrade to AGENTS.md notes anyway. For llmdoc this silently discarded the compact-continuation hook.Now
PreCompactdegrades likeSessionStart/Stop. Degraded notes also use event-appropriate timing phrases:Right before context compaction, run: …instead of the semantically wrongRun after PreCompact: …. Cursor still warns (nopreCompactin its event map) — unchanged.2.
model: inheritwas hardcoded to a mapped model nameinherit(and an absentmodel) went throughmapModeland came out as e.g.model = "gpt-5.6-sol"— freezing today's default into the generated agent, which rots as platform defaults move. All four platform branches now omit the model field forinherit/absent, letting the target platform apply its own session default. (effort/sandbox_modemapping unchanged.)3. Fresh AGENTS.md opened with a stray
---When no AGENTS.md existed, the hook section was pushed as
---\n\n# Hooks….trim(), so the file started with---— which renders as a frontmatter fence / dangling rule. The separator is now only inserted when appending to an existing AGENTS.md (with trimEnd before it).Verification
vitest: 90 passed (3 new tests: PreCompact degradation, timing phrases, inherit omission across all 4 platforms)---; both agent TOMLs have nomodel =line.Remaining (out of scope here, tracked in TokenRollAI/llmdoc#32): wiring codex hooks natively instead of AGENTS.md prose, if/when Codex exposes a stable hook config.