Skip to content

fix(prompt+tools): inject A2A/HMA docs + unify LangChain tool names with MCP - #2237

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/inject-a2a-hma-tool-instructions
Apr 28, 2026
Merged

fix(prompt+tools): inject A2A/HMA docs + unify LangChain tool names with MCP#2237
HongmingWang-Rabbit merged 1 commit into
stagingfrom
fix/inject-a2a-hma-tool-instructions

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

Workers were registering platform tools (`delegate_task`, `delegate_task_async`, `list_peers`, `check_task_status`, `send_message_to_user`, `commit_memory`, `recall_memory`) but the `build_system_prompt()` assembly never included documentation for any of them. The instruction-text functions `get_a2a_instructions()` and `get_hma_instructions()` exist in `executor_helpers.py` and have unit tests, but were never called from any production code path — workers received `system-prompt.md` content only and saw the tools as bare names with no usage guidance.

Symptom: agents called `commit_memory` and `delegate_task` without knowing they were platform tools. They worked when the agent guessed the API correctly and silently failed when the agent didn't.

Fix

`build_system_prompt()` now appends both instruction sets between the Skills section and the Peers section. The placement is intentional — A2A docs explain how to call `delegate_task`; the peer list is the data that `delegate_task` operates over, so the docs precede the peer table.

New parameter `a2a_mcp: bool = True` lets adapters opt into the CLI subprocess variant of the A2A instructions for runtimes without MCP support (ollama, custom CLI runtimes). Default `True` covers the MCP-capable majority (claude-code, hermes, langchain, crewai). Adapter callers don't need to change unless they specifically need CLI mode.

Tests

4 new regression tests in `test_prompt.py`:

  • A2A MCP variant injection (default)
  • A2A CLI variant injection (`a2a_mcp=False`, with MCP-only fields absent)
  • HMA instruction injection
  • A2A docs precede peer list ordering

Full workspace suite green: 1223 passed, 2 xfailed.

Test plan

  • `pytest workspace/tests/test_prompt.py` — 22 pass (18 existing + 4 new)
  • `WORKSPACE_ID=test pytest workspace/tests/` — 1223 pass, 2 xfailed
  • CI on this PR
  • Once merged + workspaces redeploy: confirm Design Director / worker prompts now include the A2A and HMA sections (verifiable via runtime log of system prompt or by asking an agent for its system prompt)

🤖 Generated with Claude Code

Workers were registering platform tools (delegate_task, delegate_task_async,
list_peers, check_task_status, send_message_to_user, commit_memory,
recall_memory) but the build_system_prompt assembly never included
documentation for any of them. The instruction-text functions
get_a2a_instructions() and get_hma_instructions() exist in
executor_helpers.py and have unit tests, but were not called from any
production code path — workers received system-prompt.md content only
and saw the tools as bare names with no usage guidance.

Symptom: agents called commit_memory and delegate_task without knowing
they were platform tools. They worked when the agent guessed the API
correctly and silently failed when the agent didn't.

Fix: build_system_prompt() now appends both instruction sets between
the Skills section and the Peers section. The placement is intentional —
A2A docs explain how to call delegate_task; the peer list is the data
that delegate_task operates over, so the docs precede the peer table.

New parameter `a2a_mcp: bool = True` lets adapters opt into the CLI
subprocess variant of the A2A instructions for runtimes without MCP
support (ollama, custom CLI runtimes). Default True covers the
MCP-capable majority (claude-code, hermes, langchain, crewai). Adapter
callers don't need to change unless they specifically need CLI mode.

Tests: 4 new regression tests in test_prompt.py pin
  - A2A MCP variant injection (default)
  - A2A CLI variant injection (a2a_mcp=False, with MCP-only fields absent)
  - HMA instruction injection
  - A2A docs precede peer list ordering

Full suite green: 1223 passed, 2 xfailed.
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue Apr 28, 2026
@HongmingWang-Rabbit
HongmingWang-Rabbit marked this pull request as draft April 28, 2026 23:47
Merged via the queue into staging with commit 3f99fed Apr 28, 2026
21 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/inject-a2a-hma-tool-instructions branch April 28, 2026 23:51
@HongmingWang-Rabbit HongmingWang-Rabbit changed the title fix(prompt): inject A2A and HMA tool instructions into system prompt fix(prompt+tools): inject A2A/HMA docs + unify LangChain tool names with MCP Apr 28, 2026
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…ead moves (internal#816)' (#2237) from fix/816-sop-tier-check-stale-reviews into main
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