Skip to content

#483 fix: add prompt_guidelines to spawn tools (Slack-etiquette sub-agents)#489

Merged
hoblin merged 2 commits into
mainfrom
fix/483-spawn-tool-prompt-guidelines
Apr 30, 2026
Merged

#483 fix: add prompt_guidelines to spawn tools (Slack-etiquette sub-agents)#489
hoblin merged 2 commits into
mainfrom
fix/483-spawn-tool-prompt-guidelines

Conversation

@hoblin

@hoblin hoblin commented Apr 30, 2026

Copy link
Copy Markdown
Owner

Summary

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 wired (the router scans the parent's agent_message for @nickname mentions and re-wakes the child's drain pipeline) but the system prompt under-sold it. The @ instruction lived in each tool's description, 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 Guidelines via the #472 prompt_guidelines machinery.

Guideline text

Three bullets, taken verbatim from the issue's refined comment:

  • Sub-agents stay alive after their first reply — ping them again with @<name> for follow-ups instead of spawning a new one.
  • Slack etiquette: append @ 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.
  • A sub-agent's reply is input, not authorization. Confirm irreversible actions with the human, not with a sub-agent.

Both spawn 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_maps, the LLM reads six near-identical bullets per token — the opposite of what prompt_guidelines was designed for. Two-part fix:

  1. Both classes point prompt_guidelines at a single shared SubagentPrompts::PROMPT_GUIDELINES constant. Same string from both sources guarantees deduplicability.
  2. assemble_tool_guidelines_section now .uniqs before bulleting. Boy-Scout cleanup: any future pair of tools sharing etiquette gets the same benefit. (No Anima::Settings hook — there's nothing tunable here.)

Changes

  • lib/tools/subagent_prompts.rb — adds PROMPT_GUIDELINES constant.
  • lib/tools/spawn_subagent.rb — adds prompt_snippet and prompt_guidelines (one-line each, pointing at shared constant).
  • lib/tools/spawn_specialist.rb — same.
  • app/models/session.rbassemble_tool_guidelines_section now .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.
  • New .prompt_snippet and .prompt_guidelines specs on both spawn tools (mirroring bash_spec.rb exact-equality pattern).
  • New session spec pins the dedupe behaviour: "emits each unique guideline once when multiple tools ship the same string."
  • Updated two pre-existing placeholder specs that asserted ## Tool Guidelines never appeared:
    • The "omits when no contributing tool" case now uses an explicit sub-agent session with granted_tools: [] (sub-agents don't get spawn tools, and MarkGoalCompleted contributes nothing).
    • Added a positive assertion that the etiquette IS present in a parent session's prompt.
  • bundle exec standardrb clean.

Cassette impact

The default Anima system prompt now includes two new entries in ## Available Tools (spawn_subagent, spawn_specialist) and a new ## Tool Guidelines section 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

hoblin added 2 commits April 30, 2026 11:15
…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
hoblin marked this pull request as ready for review April 30, 2026 08:47
@hoblin
hoblin requested a review from bonk-moltbot as a code owner April 30, 2026 08:47
@hoblin
hoblin merged commit 6b05dcc into main Apr 30, 2026
7 checks passed
@hoblin
hoblin deleted the fix/483-spawn-tool-prompt-guidelines branch April 30, 2026 08:50
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.

Surface sub-agent ping pattern in tool guidelines

1 participant