Skip to content

fix(session-start): eliminate per-subagent re-fire payload bloat (v6.1.2)#46

Merged
intel352 merged 1 commit into
mainfrom
fix/session-start-payload-bloat-2026-05-27T1550
May 27, 2026
Merged

fix(session-start): eliminate per-subagent re-fire payload bloat (v6.1.2)#46
intel352 merged 1 commit into
mainfrom
fix/session-start-payload-bloat-2026-05-27T1550

Conversation

@intel352
Copy link
Copy Markdown
Contributor

Summary

  • SessionStart hook was re-embedding the full ~8 KB using-autodev SKILL.md body on every fire. Codex's run_pending_session_start_hooks fires per subagent spawn (one user prompt dispatching 6+ subagents → 6+ identical 8 KB blobs). Claude Code re-fires on every compact.
  • hooks/session-start now emits a ~340-byte pointer instead. Both hosts discover skills natively via SKILL.md frontmatter, so re-injecting the body was redundant context bloat.
  • Subagent fires (agent_id populated) short-circuit to zero-byte output. agent_type alone is NOT used — Claude Code sets it on top-level claude --agent <name> main sessions which still deserve the pointer.
  • Per-session_id:source_kind dedup guards against host re-fire bugs for startup/clear; compact/resume intentionally not deduped so each legit lifecycle event still emits resumption context.
  • Stale-state wipe rekeyed on session_id transitions, not source == "startup" (old signal defeated dedup on re-fires).
  • Version 6.1.1 → 6.1.2 across all four manifests so release-tag workflow auto-tags on merge.

Test plan

  • tests/hook-contracts.sh — 47 assertions PASS
  • tests/version-check.sh — all four manifests agree on 6.1.2
  • tests/skill-content-grep.sh — host-neutral skill content
  • Manual scenario coverage:
    • Claude subagent (agent_id set) → empty output, exit 0
    • Claude claude --agent top-level (agent_type only) → pointer emitted
    • Codex rapid re-fire (same session+source startup) → dedup, exit 0
    • Legitimate compact/resume (same session) → resumption context emitted every time
    • Fresh session_id after dedup → state reset, pointer re-emitted

Root cause references

🤖 Generated with Claude Code

…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>
@intel352 intel352 merged commit 8649aea into main May 27, 2026
5 checks passed
@intel352 intel352 deleted the fix/session-start-payload-bloat-2026-05-27T1550 branch May 27, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant