fix(session-start): eliminate per-subagent re-fire payload bloat (v6.1.2)#46
Merged
Merged
Conversation
…1.2) The SessionStart hook was re-embedding the full ~8 KB using-autodev SKILL.md body on every fire. Codex's run_pending_session_start_hooks was observed firing per subagent spawn -- a single user prompt that dispatched 6+ subagents produced 6+ identical 8 KB blobs in the transcript. Claude Code re-fires the same payload on every compaction. Changes to hooks/session-start: - Emit a ~340-byte pointer instead of the full SKILL.md body. Both Claude Code and Codex discover skills natively via SKILL.md frontmatter, so the body inject was redundant context bloat. - Skip injection when payload contains agent_id. Per both hosts' docs, agent_id is "present only when the hook fires inside a subagent call." agent_type alone is NOT used because Claude Code populates it on top-level `claude --agent <name>` main sessions, which still deserve the pointer. - Per-session_id:source_kind dedup for startup/clear fires. Guards against host re-fire bugs (Codex rapid fires, plugin reload loops, MCP init re-triggers). compact/resume are intentionally NOT deduped so each legitimate lifecycle event still emits its resumption context. - Stale-state wipe rekeyed on session_id transitions rather than the brittle source == "startup" signal. The old signal made re-fires of the same session's startup event repeatedly wipe SEEN_FILE, defeating dedup. Version bump to 6.1.2 in all four manifests (plugin.json, marketplace.json, cursor-plugin/plugin.json) so release-tag workflow auto-tags on merge. Tests: hook-contracts.sh (47 assertions), version-check.sh, skill-content-grep.sh all pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
using-autodevSKILL.md body on every fire. Codex'srun_pending_session_start_hooksfires per subagent spawn (one user prompt dispatching 6+ subagents → 6+ identical 8 KB blobs). Claude Code re-fires on every compact.hooks/session-startnow emits a ~340-byte pointer instead. Both hosts discover skills natively via SKILL.md frontmatter, so re-injecting the body was redundant context bloat.agent_idpopulated) short-circuit to zero-byte output.agent_typealone is NOT used — Claude Code sets it on top-levelclaude --agent <name>main sessions which still deserve the pointer.session_id:source_kinddedup guards against host re-fire bugs forstartup/clear;compact/resumeintentionally not deduped so each legit lifecycle event still emits resumption context.source == "startup"(old signal defeated dedup on re-fires).Test plan
tests/hook-contracts.sh— 47 assertions PASStests/version-check.sh— all four manifests agree on 6.1.2tests/skill-content-grep.sh— host-neutral skill contentagent_idset) → empty output, exit 0claude --agenttop-level (agent_typeonly) → pointer emittedcompact/resume(same session) → resumption context emitted every timesession_idafter dedup → state reset, pointer re-emittedRoot cause references
agent_idis "present only when the hook fires inside a subagent call"agent_idsemanticsrun_pending_session_start_hooksfires per subagent spawn🤖 Generated with Claude Code