VI · Multi-AgentEmerging

Agent-as-Tool Embedding

also known as Sub-Agent as Function, Nested Agent, Agent Wrapped in a Tool Signature

Wrap a sub-agent (with its own loop, prompt, and tool palette) behind a single function-shaped tool signature, so the parent agent calls it like any other tool and never sees the sub-agent's internal turns.

This pattern helps complete certain larger patterns —

  • specialisesOrchestrator-Workers★★An orchestrator dynamically breaks a task into subtasks at runtime and delegates each to a worker LLM, then synthesises results.
  • specialisesHierarchical Agents★★Organise agents in a tree where higher-level agents decompose tasks for lower-level agents, recursively.

Context

A parent agent is handling an overall goal and runs into a bounded sub-task — search the web for a topic and summarise the findings, plan a multi-day itinerary, audit a directory of files — that deserves its own focused loop with its own model, tool palette, and step budget. The parent does not need to watch the sub-task being solved; it only needs the answer.

Problem

If the parent watches every turn the sub-agent takes, the parent's context window fills up with intermediate searches and tool calls that have nothing to do with the parent's own job, and the parent's reasoning starts to entangle with the sub-agent's internals. Building a full multi-agent broadcast bus to coordinate the two is far more machinery than the situation needs. Without a clean boundary, the team ends up choosing between bloated parent context and over-engineered coordination.

Forces

  • Nested loops add abstraction; parent shouldn't care about how sub solves it.
  • The function-shaped tool signature is already the agent's native composition unit.
  • Sub-agent failure has to surface cleanly to the parent.
  • Cost attribution across nesting depth is non-trivial.

Example

A travel-planning agent needs to research hotel options, which itself takes ten or twenty turns of search and filtering. Putting all those turns into the parent's transcript bloats context and entangles the planner with hotel-search internals. The team wraps the hotel sub-agent behind a single function-shaped tool: the parent calls research_hotels(criteria) and gets back a structured shortlist. The sub-agent's internal turns stay sealed behind that signature.

Diagram

Solution

Therefore:

Define the sub-agent as `def sub_agent(task: str, ...) -> Result`. The parent calls it like any other tool. Inside the function: a fresh agent loop with its own model, tool palette, and step budget runs to completion or failure, returning a structured result. Parent context records only the call and the return value. Step budget and timeout are enforced by the wrapper, not by the sub-agent's prompt.

What this pattern forbids. The parent may not access the sub-agent's intermediate turns; only the return value crosses the boundary.

The smaller patterns that complete this one —

  • usesTool Use★★Let the LLM produce typed calls against an external toolkit instead of producing free-form text the surrounding system has to parse.

And the patterns that stand alongside it, or against it —

  • complementsSubagent IsolationRun subagents in isolated workspaces so their writes do not collide and parallelism is safe.
  • complementsStep Budget★★Cap the number of tool calls or loop iterations the agent is allowed within a single request.
  • complementsRL-Trained Conductor Orchestrator·Train a small meta-model with reinforcement learning to dispatch sub-tasks across a pool of frontier LLM workers, learning the communication topology end-to-end and allowing the conductor to recursively invoke itself as a worker.
  • complementsVisual Workflow Graph★★Express agentic logic as a visual graph of typed nodes connected on a canvas with Start and End nodes so non-coding stakeholders can read and edit the flow.
  • complementsBPMN/DMN Deterministic Shell Around AgentBPMN processes and DMN decision tables form the deterministic spine; LLM-driven agents are invoked only at explicit 'unstructured problem' nodes inside the process.
  • composes-withAgentic Behavior Tree·Borrow the behavior-tree formalism: leaves are LLM calls or tools that return success/failure; a tree of selectors and sequences orchestrates control flow.

Neighbourhood

Click any neighbour to follow the language. Scroll to zoom, drag to pan.