Skip to content

feat: agent orchestration education — teach agents when to use chat_with_agent vs fan_out vs async #505

Description

@vybe

Summary

Surfaced during work on #498. Agents calling other agents have no in-band guidance on which delegation pattern to use, leading to predictable misuse (e.g., chat_with_agent parallel=true async=false for fan-out, which doesn't queue and produces terminal capacity rejections).

The platform offers three distinct patterns but documents only one of them in the agent's system prompt and undersells the trade-offs in the MCP tool descriptions.

Component

Backend / Platform Prompt Service / MCP Server (chat tool)

Priority

P2 — improves observable agent behavior platform-wide; complements the platform fix in #498.

What agents see today

src/backend/services/platform_prompt_service.py:38 mentions only:

- mcp__trinity__chat_with_agent(agent_name, message) - Delegate tasks to other agents

No mention of parallel, async, fan_out, or capacity behavior.

src/mcp-server/src/tools/chat.ts — the chat_with_agent description hints at the modes but doesn't tell agents that sync parallel mode does NOT queue at capacity. The fan_out tool exists right next to it but the chat_with_agent description doesn't pointer to it.

Proposed Changes

1. platform_prompt_service.py — Replace the Agent Collaboration subsection

Replace the single-bullet chat_with_agent mention with three named patterns:

  • Conversational handoff — chat_with_agent(name, message). Sequential, queue-backed, maintains context.
  • Single parallel task — chat_with_agent(name, message, parallel=true, async=true). Stateless, returns execution_id; poll for result. Capacity overflow IS absorbed.
  • Fan-out workload — fan_out(name, [tasks]). Designed for N independent tasks with built-in concurrency control. Use whenever there are ≥3 independent tasks for the same agent.

Plus a short capacity note explaining when each mode queues vs fails.

2. src/mcp-server/src/tools/chat.ts — Tighten chat_with_agent description

Add a 'Capacity behavior' subsection that names the three (parallel, async) combinations and what each does at capacity. Add explicit pointer: 'For fan-out (≥3 tasks to same agent), use fan_out instead.'

3. Optional — surface fan_out in list_agents response

When an agent lists its collaborators, hint at the recommended delegation pattern based on permissions.

Acceptance Criteria

  • Platform system prompt distinguishes the three orchestration patterns with capacity model.
  • chat_with_agent MCP tool description states the at-capacity behavior of each mode and pointers to fan_out.
  • Manual smoke test: a fresh agent's first attempt at fan-out picks fan_out or async-parallel, not sync-parallel.
  • Token-cost delta on platform prompt is bounded (≤ ~30 lines added).

Out of Scope

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-lowComplexity: low (board points 1-3)priority-p2Importantstatus-readyGreenlit and ready for development (vetted; counterpart to status-incubating)theme-devexTheme: DevExtype-featureNew functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions