Skip to content

fix(hooks): inject condensed fallback instructions on SubagentStart#634

Open
Vrindakr3300 wants to merge 2 commits into
DietrichGebert:mainfrom
Vrindakr3300:fix/issue-597-subagent-condensed-instructions
Open

fix(hooks): inject condensed fallback instructions on SubagentStart#634
Vrindakr3300 wants to merge 2 commits into
DietrichGebert:mainfrom
Vrindakr3300:fix/issue-597-subagent-condensed-instructions

Conversation

@Vrindakr3300

@Vrindakr3300 Vrindakr3300 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

This PR resolves the subagent token overhead issue by switching the SubagentStart hook payload from the full mode-filtered SKILL.md (getPonytailInstructions) to the condensed fallback ruleset or independent mode pointer line.

Why

The full instruction set contains comparison tables and slash-command directions designed for human session configuration. Subagent workers spawned for one-off tasks do not need these examples or controls.
By switching to the condensed instructions, we reduce the injected payload per subagent spawn by ~49% (saving roughly 600+ tokens per subagent) without losing any of the operational rules (the ladder, formatting, and boundary rules).
Furthermore, if the session is currently in an independent mode such as review, we preserve the specific pointer line (PONYTAIL MODE ACTIVE — level: review. Behavior defined by /ponytail-review skill.) instead of using the generic developer fallback rules.

Changes

  • hooks/ponytail-instructions.js: Created and exported the getSubagentInstructions(mode) helper, which checks if the mode is independent (e.g. review) to output the pointer line, falling back to getFallbackInstructions otherwise.
  • hooks/ponytail-subagent.js: Replaced import and invocation of getPonytailInstructions with getSubagentInstructions.
  • tests/hooks.test.js:
    • Added assertions verifying that the injected subagent hook payload contains core rules but does not include the Intensity or Example sections, while keeping the regex matcher logic untouched.
    • Added a new test case asserting that the review mode pointer line is correctly preserved when running the subagent hook in review mode.

Closes #597
Refs #502

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.

SubagentStart always sends the full SKILL.md — reuse the shipped condensed fallback for subagent workers

1 participant