#483 fix: add prompt_guidelines to spawn tools (Slack-etiquette sub-agents)#489
Merged
Conversation
…gents) Sub-agents and specialists spawned via +Tools::SpawnSubagent+ / +Tools::SpawnSpecialist+ are persistent collaborators. The agent can keep talking to them across turns by addressing them with +@<name>+ — exactly like pinging a colleague in Slack. The behaviour was already implemented (router scans the parent's +agent_message+ for +@Nickname+ mentions and re-wakes the child's drain pipeline) but the system prompt under-sold the affordance: the +@+ instruction was buried in each tool's +description+, where the LLM only sees it at tool-call time. Lifts the etiquette into the cached system prompt via the +#472+ +prompt_guidelines+ machinery. Both spawn tools now contribute three verbatim bullets (text directly from the issue's refined comment) via a shared +Tools::SubagentPrompts::PROMPT_GUIDELINES+ constant. Both tools also gain a +prompt_snippet+ so they appear in the +## Available Tools+ menu. ## Why a shared constant + assembler dedupe If both spawn tools ship the same three lines and the assembler (+Session#assemble_tool_guidelines_section+) just +flat_map+s, the LLM reads six near-identical bullets per token. Two-part fix: 1. Both classes point +prompt_guidelines+ at the single shared +SubagentPrompts::PROMPT_GUIDELINES+ constant. 2. +assemble_tool_guidelines_section+ now +.uniq+s before bulleting, so the section emits each unique guideline once. Boy-Scout cleanup: any future pair of tools sharing etiquette gets the same benefit. ## Test changes * New +.prompt_snippet+ and +.prompt_guidelines+ contract specs on both spawn tools, mirroring the +bash_spec.rb+ exact-equality pattern. * New session spec pinning the assembler dedupe behaviour. * Updated two pre-existing placeholder specs that asserted the +"## Tool Guidelines"+ section never appears (they were waiting for the first contributing tool — now spawn_subagent/specialist): - The "omits when no contributing tool" assertion now uses an explicit sub-agent session with +granted_tools: []+ (sub-agents don't get the spawn tools and +MarkGoalCompleted+ contributes nothing). - Added a positive assertion that the etiquette IS present in a parent session's prompt. 295 affected specs green. +standardrb+ clean. Closes #483
hoblin
marked this pull request as ready for review
April 30, 2026 08:47
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
Sub-agents and specialists spawned via
Tools::SpawnSubagent/Tools::SpawnSpecialistare persistent collaborators — the agent can keep talking to them across turns by addressing them with@<name>, exactly like pinging a colleague in Slack. The behaviour was already wired (the router scans the parent'sagent_messagefor@nicknamementions and re-wakes the child's drain pipeline) but the system prompt under-sold it. The@instruction lived in each tool'sdescription, where the LLM only sees it at tool-call time — not in the cached system prompt where it would steer behaviour every turn.This lifts the etiquette into
## Tool Guidelinesvia the #472prompt_guidelinesmachinery.Guideline text
Three bullets, taken verbatim from the issue's refined comment:
@<name>for follow-ups instead of spawning a new one.@when addressing them (@scout, please dig further); drop the@when mentioning them (scout's analysis showed…). The@is what triggers a new request to that sub-agent.Both spawn tools also gain a
prompt_snippetso they appear in the## Available Toolsmenu.Why a shared constant + assembler dedupe
If both spawn tools ship the same three lines and the assembler (
Session#assemble_tool_guidelines_section) justflat_maps, the LLM reads six near-identical bullets per token — the opposite of whatprompt_guidelineswas designed for. Two-part fix:prompt_guidelinesat a single sharedSubagentPrompts::PROMPT_GUIDELINESconstant. Same string from both sources guarantees deduplicability.assemble_tool_guidelines_sectionnow.uniqs before bulleting. Boy-Scout cleanup: any future pair of tools sharing etiquette gets the same benefit. (NoAnima::Settingshook — there's nothing tunable here.)Changes
lib/tools/subagent_prompts.rb— addsPROMPT_GUIDELINESconstant.lib/tools/spawn_subagent.rb— addsprompt_snippetandprompt_guidelines(one-line each, pointing at shared constant).lib/tools/spawn_specialist.rb— same.app/models/session.rb—assemble_tool_guidelines_sectionnow.uniqs the bullets and the YARD comment is updated to explain why.Test plan
bundle exec rspec spec/lib/tools/spawn_subagent_spec.rb spec/lib/tools/spawn_specialist_spec.rb spec/models/session_spec.rb— 295/295 green..prompt_snippetand.prompt_guidelinesspecs on both spawn tools (mirroringbash_spec.rbexact-equality pattern).## Tool Guidelinesnever appeared:granted_tools: [](sub-agents don't get spawn tools, andMarkGoalCompletedcontributes nothing).bundle exec standardrbclean.Cassette impact
The default Anima system prompt now includes two new entries in
## Available Tools(spawn_subagent, spawn_specialist) and a new## Tool Guidelinessection with three bullets. Any cassette that uses the default prompt will need to be re-recorded — leaving CI to surface them; success-path cassettes are re-recordable.Closes
Closes #483
Related
prompt_snippet/prompt_guidelinesinfrastructurefrom_*tool calls in the main loop #480 — sibling issue: phantomfrom_<name>tool calls (the same@-addressing system surfaced as confusion)