Agentic Architectures

Catalogue / Tools & Action

LLMCompiler

Plan the calls as a dependency graph and run the ready ones together

Shape
orchestrator
Model calls
1 planner + 1 joiner per round, 1 to 3 rounds (2 to 6); tool calls are plain code
Latency
low
Complexity
medium

Also known as Parallel function calling, Task DAG planner

1

Why run tool calls one at a time when they do not depend on each other?

An ordered list of steps hides which calls need another call's result. LLMCompiler has the planner write the calls as a graph, each with the calls it depends on. A scheduler in plain code starts every call whose inputs are ready, so independent calls run at the same time. A joiner then answers or asks for a new plan.

You may need it if

  • The agent makes several lookups in a row and none of them uses another's result.
  • Most of the waiting time is model turns between tool calls, not the tools themselves.
  • Users compare several items, and each item needs the same few lookups.
2

When does a graph of calls bring nothing, or cause harm?

Use it when

  • A request needs several tool calls and many of them are independent of each other.
  • Dependencies between calls are simple, such as one call's output used as another's argument.
  • The tools are safe to run at the same time, which is usually true of reads.

Avoid it when

  • Every call needs the result of the one before. The graph is a straight chain and nothing runs in parallel.
    Use ReWOO instead
  • Each next call can only be chosen after reading the last result. The joiner would ask for a new plan after every call.
    Use ReAct instead
  • Calls change records or send messages and must not run at the same time. The graph records data dependencies only.
    Use Planning instead
  • The parallel parts need judgement from different specialists, not function calls.
    Use Supervisor & Specialists instead

What it costs

Model calls
1 planner + 1 joiner per round, 1 to 3 rounds (2 to 6); tool calls are plain code
Latency
low
Complexity
medium
3

How does the scheduler know which calls can start?

The planner writes tasks, each with a tool, an input and the tasks it depends on. The scheduler starts every task whose dependencies are finished and pastes their results into its input. When no task is left, a joiner reads all results and either answers or sends them back to the planner.

resultsunlockmore tasksno task left torunsomethingmissing,replans leftcan answer, orreplans used upTask: The task or question. The tool list with descriptions is already configured.TaskPlanner: Writes the tasks, each with one tool, its input and the tasks it depends on. On a replan, adds new tasks.PlannerTask graph: Every task with its dependencies and, once it has run, its result.Task graphTask fetching unit: Plain code. Starts each task whose dependencies are finished and fills in their results. No model call.Task fetchingunitTools: Your functions. Several run at the same time when their tasks do not depend on each other.ToolsJoiner: Reads the task and all results. Writes the answer, or says what is missing and asks for a new plan.JoinerAnswer: The answer, with the tasks that ran, their results and the number of plans used.Answer
  1. Step 1 of 6

    The plan is a graph

    For "Prepare a renewal brief for our largest customer", the planner writes four tasks: 1 largest_customer, 2 invoices($1), 3 open_tickets($1), 4 usage($1). Tasks 2 to 4 each list task 1 as a dependency. $1 stands for its result.

  2. Step 2 of 6

    Only one task is ready

    The scheduler looks for tasks whose dependencies are all finished. At the start that is task 1 alone. It runs and its result, the customer's name, is stored in the graph.

  3. Step 3 of 6

    Three calls at once

    Task 1's result makes tasks 2, 3 and 4 ready together. The scheduler replaces $1 with the name in each input and starts the three calls at the same time. No model is asked in between.

  4. Step 4 of 6

    The joiner reads everything

    When no task is left, the joiner receives the task and the four results. This is the first time a model sees a tool result in this round.

  5. Step 5 of 6

    A new plan when something is missing

    The tickets mention an outage that the brief should explain. The joiner asks for a new plan and says what is missing. The planner sees the earlier results and adds task 5, incident_report. It runs, and the joiner is called again.

  6. Step 6 of 6

    The answer

    The joiner writes the brief from the five results. After two replans it must answer with what it has and name what is still missing.

What each part does
Task
The task or question. The tool list with descriptions is already configured.
Planner
Writes the tasks, each with one tool, its input and the tasks it depends on. On a replan, adds new tasks.
Task graph
Every task with its dependencies and, once it has run, its result.
Task fetching unit
Plain code. Starts each task whose dependencies are finished and fills in their results. No model call.
Tools
Your functions. Several run at the same time when their tasks do not depend on each other.
Joiner
Reads the task and all results. Writes the answer, or says what is missing and asks for a new plan.
Answer
The answer, with the tasks that ran, their results and the number of plans used.
  • Planner → Task graph: tasks and dependencies
  • Task graph → Task fetching unit: tasks ready to start
  • Task fetching unit → Tools: ready tasks together
  • Tools → Task fetching unit: results unlock more tasks
  • Task fetching unit → Task graph: results
  • Task fetching unit → Joiner: no task left to run
  • Task graph → Joiner: tasks and results
  • Joiner → Planner: something missing, replans left
  • Joiner → Answer: can answer, or replans used up

Where it connects

Entry
task
TaskQuestion

A task or question that needs several tool calls, many of them independent. The tools and their descriptions are already configured.

Exit
answer
AnswerOutcome

When: The joiner judges the results sufficient, or the replan limit is reached.

The answer, then each task that ran with its tool, input and result, the number of plans used, and what is still missing if the limit cut the run short.

Working memory for one run
task-graph
PlanOutcome

Numbered tasks, each with a tool, an input, the tasks it depends on and its result once it has run. A replan adds tasks and never removes finished ones.

4

What do I ask my assistant to set up?

The agents to launch

Planner

Break the task into tool calls. Give each call a number, one tool, its input and the numbers of the calls whose results it needs. Write $1 in an input where the result of call 1 goes. List a dependency only when the result is really needed, so that independent calls can run together. On a replan, keep the numbering going and add only calls that are still missing.

Sees: The task and the tool list. On a replan, also the earlier calls with their results and the joiner's note on what is missing.

Joiner

Read the task and the results of every call. If they are enough, write the final answer from them. If something needed is missing, ask for a new plan and state in one line what is missing. When told that no replan is left, answer with what you have and say what is still unknown.

Sees: The task and every call with its tool, input and result. It cannot call tools or edit the graph.

A prompt you can paste

Works with any assistant that can launch sub-agents. It contains the agents, the procedure and the stop rule above.

Framework-agnostic prompt
You are the orchestrator of a multi-agent workflow that follows the "LLMCompiler" architecture.
Launch every agent listed below as a separate sub-agent with its own context. Give each agent only the context stated for it. Do not do an agent's work yourself. If you cannot launch sub-agents, play each agent in a clearly separated turn and never let it use what is withheld from it.

# Task
[Describe your task here]

# LLMCompiler
Plan the calls as a dependency graph and run the ready ones together.
Input: the task above. It must provide: A task or question that needs several tool calls, many of them independent. The tools and their descriptions are already configured. If something essential is missing, ask for it before starting.

Agents to launch:
- Planner: Break the task into tool calls. Give each call a number, one tool, its input and the numbers of the calls whose results it needs. Write $1 in an input where the result of call 1 goes. List a dependency only when the result is really needed, so that independent calls can run together. On a replan, keep the numbering going and add only calls that are still missing.
  Context for this agent: The task and the tool list. On a replan, also the earlier calls with their results and the joiner's note on what is missing.
- Joiner: Read the task and the results of every call. If they are enough, write the final answer from them. If something needed is missing, ask for a new plan and state in one line what is missing. When told that no replan is left, answer with what you have and say what is still unknown.
  Context for this agent: The task and every call with its tool, input and result. It cannot call tools or edit the graph.

Procedure:
1. Write the tool list with a one-line description each. Mark the tools that change something. Those must not run in parallel.
2. Launch the planner on the task. Store its tasks as the graph. Drop a task that names an unknown tool or depends on a task that does not exist.
3. In plain code, start every task whose dependencies all have a result. Replace each $n in its input with the result of task n. Run the ready tasks at the same time.
4. Store each result in the graph and repeat until no task is left. If tasks remain and none is ready, record them as not run.
5. Launch the joiner on the task and all results. If it answers, return the answer.
6. If it asks for a new plan, send the planner the tasks so far, their results and the joiner's note. Allow at most 2 replans and 12 tasks in total.

Stop rule: Stop when the joiner answers. After 2 replans, or once 12 tasks have run, the joiner must answer with what it has and list what is missing.

Exit:
- `answer`, when: The joiner judges the results sufficient, or the replan limit is reached. Deliver: The answer, then each task that ran with its tool, input and result, the number of plans used, and what is still missing if the limit cut the run short.

# Final deliverable
The answer, then the tasks that ran with their results, the number of plans used and, if the limit was hit, what is still missing.

The same thing in code

LangGraph, python, package langgraph
import asyncio
from typing import Literal, TypedDict

from langchain.chat_models import init_chat_model
from langchain_core.messages import HumanMessage, SystemMessage
from langgraph.graph import END, START, StateGraph
from pydantic import BaseModel

MAX_REPLANS, MAX_TASKS = 2, 12


async def crm(query: str) -> str:
    return f"stub: CRM record for {query}"  # plug in your systems; these must be safe to run together


async def billing(customer: str) -> str:
    return f"stub: invoices for {customer}"


async def support(customer: str) -> str:
    return f"stub: open tickets for {customer}"


TOOLS = {"crm": crm, "billing": billing, "support": support}
PLANNER = ("Break the task into tool calls. Give each a number, one tool, its input and the numbers of the calls "
           "whose results it needs. Write $1 where the result of call 1 goes. List a dependency only when the "
           "result is needed. On a replan, keep the numbering going and add only what is missing.")
JOINER = ("Read the task and every result. If they are enough, write the final answer. If not, ask for a new "
          "plan and say in one line what is missing. If no replan is left, answer and say what is unknown.")


class Task(BaseModel):
    id: int
    tool: str
    input: str  # may contain $1, $2: results of the tasks it depends on
    depends_on: list[int]


class Graph(BaseModel):
    tasks: list[Task]


class Join(BaseModel):
    action: Literal["answer", "replan"]
    text: str  # the answer, or what is missing


class State(TypedDict):
    task: str
    tasks: list[Task]
    results: dict[int, str]
    plans: int
    missing: str
    answer: str


model = init_chat_model("anthropic:claude-sonnet-5-5")


def render(state: State) -> str:
    return "\n".join(f"{t.id}. {t.tool}[{t.input}] -> {state['results'].get(t.id, '(pending)')}" for t in state["tasks"]) or "(none)"


async def planner(state: State) -> dict:
    prompt = f"Task: {state['task']}\nTools: {', '.join(TOOLS)}"
    if state["plans"]:
        prompt += f"\n\nCalls so far:\n{render(state)}\n\nStill missing: {state['missing']}"
    new = Graph.model_validate(await model.with_structured_output(Graph).ainvoke([SystemMessage(PLANNER), HumanMessage(prompt)]))
    known = {t.id for t in state["tasks"]}
    added = [t for t in new.tasks if t.id not in known][: MAX_TASKS - len(known)]
    return {"tasks": state["tasks"] + added, "plans": state["plans"] + 1}


async def call(task: Task, results: dict[int, str]) -> str:
    text = task.input
    for dep in sorted(task.depends_on, reverse=True):
        text = text.replace(f"${dep}", results.get(dep, ""))
    tool = TOOLS.get(task.tool)
    try:
        return await tool(text) if tool else f"error: unknown tool {task.tool}"
    except Exception as exc:
        return f"error: {exc}"


async def scheduler(state: State) -> dict:
    # plain code: a task starts when all the tasks it depends on have a result
    results = dict(state["results"])
    while waiting := [t for t in state["tasks"] if t.id not in results]:
        ready = [t for t in waiting if all(d in results for d in t.depends_on)]
        if not ready:  # a cycle or a missing dependency: stop, do not wait
            results.update({t.id: "not run: a dependency never resolved" for t in waiting})
            break
        outputs = await asyncio.gather(*(call(t, results) for t in ready))  # ready tasks run together
        results.update({t.id: out for t, out in zip(ready, outputs)})
    return {"results": results}


async def joiner(state: State) -> dict:
    last = state["plans"] > MAX_REPLANS or len(state["tasks"]) >= MAX_TASKS
    prompt = f"Task: {state['task']}\n\nCalls and results:\n{render(state)}"
    if last:
        prompt += "\n\nNo replan is left. Answer now and say what is still unknown."
    join = Join.model_validate(await model.with_structured_output(Join).ainvoke([SystemMessage(JOINER), HumanMessage(prompt)]))
    if join.action == "replan" and not last:
        return {"missing": join.text}
    return {"answer": join.text, "missing": ""}


builder = StateGraph(State)
builder.add_node("planner", planner)
builder.add_node("scheduler", scheduler)
builder.add_node("joiner", joiner)
builder.add_edge(START, "planner")
builder.add_edge("planner", "scheduler")
builder.add_edge("scheduler", "joiner")
builder.add_conditional_edges("joiner", lambda s: END if s["answer"] else "planner", ["planner", END])
graph = builder.compile()


async def run(task: str) -> dict:
    s = await graph.ainvoke({"task": task, "tasks": [], "results": {}, "plans": 0, "missing": "", "answer": ""})
    ran = [{**t.model_dump(), "result": s["results"].get(t.id)} for t in s["tasks"]]
    return {"answer": s["answer"], "tasks": ran, "plans": s["plans"]}

The scheduler runs in waves. The paper's unit starts each task the moment its inputs are ready, even while the planner is still streaming the plan.

Claude Agent SDK, python, package claude-agent-sdk
import asyncio
from typing import Literal

from claude_agent_sdk import AgentDefinition, ClaudeAgentOptions, ResultMessage, query
from pydantic import BaseModel

MAX_REPLANS, MAX_TASKS = 2, 12


async def crm(query_text: str) -> str:
    return f"stub: CRM record for {query_text}"  # plug in your systems; these must be safe to run together


async def billing(customer: str) -> str:
    return f"stub: invoices for {customer}"


async def support(customer: str) -> str:
    return f"stub: open tickets for {customer}"


TOOLS = {"crm": crm, "billing": billing, "support": support}

AGENTS = {
    "planner": AgentDefinition(
        description="Writes the tool calls as a dependency graph.",
        prompt="Break the task into tool calls. Give each a number, one tool, its input and the numbers of the calls "
               "whose results it needs. Write $1 where the result of call 1 goes. List a dependency only when the "
               "result is needed. On a replan, keep the numbering going and add only what is missing.",
    ),
    "joiner": AgentDefinition(
        description="Answers from the results, or asks for a new plan.",
        prompt="Read the task and every result. If they are enough, write the final answer. If not, ask for a new "
               "plan and say in one line what is missing. If no replan is left, answer and say what is unknown.",
    ),
}


class Task(BaseModel):
    id: int
    tool: str
    input: str  # may contain $1, $2: results of the tasks it depends on
    depends_on: list[int]


class Graph(BaseModel):
    tasks: list[Task]


class Join(BaseModel):
    action: Literal["answer", "replan"]
    text: str  # the answer, or what is missing


async def delegate[T: BaseModel](agent: str, message: str, schema: type[T]) -> T:
    # one fresh session per call, so each sub-agent sees only the message it is given
    options = ClaudeAgentOptions(
        agents=AGENTS,
        allowed_tools=["Agent"],
        output_format={"type": "json_schema", "schema": schema.model_json_schema()},
    )
    prompt = f"Delegate this to the {agent} agent, passing it verbatim, and return its reply unchanged:\n\n{message}"
    async for msg in query(prompt=prompt, options=options):
        if isinstance(msg, ResultMessage):
            return schema.model_validate(msg.structured_output)
    raise RuntimeError("no result")


async def call(task: Task, results: dict[int, str]) -> str:
    text = task.input
    for dep in sorted(task.depends_on, reverse=True):
        text = text.replace(f"${dep}", results.get(dep, ""))
    tool = TOOLS.get(task.tool)
    try:
        return await tool(text) if tool else f"error: unknown tool {task.tool}"
    except Exception as exc:
        return f"error: {exc}"


async def schedule(tasks: list[Task], results: dict[int, str]) -> None:
    # plain code: a task starts when all the tasks it depends on have a result
    while waiting := [t for t in tasks if t.id not in results]:
        ready = [t for t in waiting if all(d in results for d in t.depends_on)]
        if not ready:  # a cycle or a missing dependency: stop, do not wait
            results.update({t.id: "not run: a dependency never resolved" for t in waiting})
            return
        outputs = await asyncio.gather(*(call(t, results) for t in ready))  # ready tasks run together
        results.update({t.id: out for t, out in zip(ready, outputs)})


async def run(task: str) -> dict:
    tasks: list[Task] = []
    results: dict[int, str] = {}  # with the tasks, this is the graph store
    plans, missing = 0, ""
    while True:
        log = "\n".join(f"{t.id}. {t.tool}[{t.input}] -> {results[t.id]}" for t in tasks)
        prompt = f"Task: {task}\nTools: {', '.join(TOOLS)}"
        if plans:
            prompt += f"\n\nCalls so far:\n{log}\n\nStill missing: {missing}"
        new = await delegate("planner", prompt, Graph)
        plans += 1
        known = {t.id for t in tasks}
        tasks += [t for t in new.tasks if t.id not in known][: MAX_TASKS - len(known)]
        await schedule(tasks, results)
        last = plans > MAX_REPLANS or len(tasks) >= MAX_TASKS
        log = "\n".join(f"{t.id}. {t.tool}[{t.input}] -> {results[t.id]}" for t in tasks)
        ask = f"Task: {task}\n\nCalls and results:\n{log}"
        if last:
            ask += "\n\nNo replan is left. Answer now and say what is still unknown."
        join = await delegate("joiner", ask, Join)
        if join.action == "answer" or last:
            ran = [{**t.model_dump(), "result": results[t.id]} for t in tasks]
            return {"answer": join.text, "tasks": ran, "plans": plans}
        missing = join.text

The tools run in your own code so that they can run together. The scheduler works in waves; the paper's unit starts each task as soon as its inputs are ready.

OpenAI Agents SDK, python, package openai-agents
import asyncio
from typing import Literal

from agents import Agent, Runner
from pydantic import BaseModel

MAX_REPLANS, MAX_TASKS = 2, 12


async def crm(query: str) -> str:
    return f"stub: CRM record for {query}"  # plug in your systems; these must be safe to run together


async def billing(customer: str) -> str:
    return f"stub: invoices for {customer}"


async def support(customer: str) -> str:
    return f"stub: open tickets for {customer}"


TOOLS = {"crm": crm, "billing": billing, "support": support}


class Task(BaseModel):
    id: int
    tool: str
    input: str  # may contain $1, $2: results of the tasks it depends on
    depends_on: list[int]


class Graph(BaseModel):
    tasks: list[Task]


class Join(BaseModel):
    action: Literal["answer", "replan"]
    text: str  # the answer, or what is missing


planner = Agent(
    name="Planner",
    instructions="Break the task into tool calls. Give each a number, one tool, its input and the numbers of the calls "
                 "whose results it needs. Write $1 where the result of call 1 goes. List a dependency only when the "
                 "result is needed. On a replan, keep the numbering going and add only what is missing.",
    output_type=Graph,
)
joiner = Agent(
    name="Joiner",
    instructions="Read the task and every result. If they are enough, write the final answer. If not, ask for a new "
                 "plan and say in one line what is missing. If no replan is left, answer and say what is unknown.",
    output_type=Join,
)


async def call(task: Task, results: dict[int, str]) -> str:
    text = task.input
    for dep in sorted(task.depends_on, reverse=True):
        text = text.replace(f"${dep}", results.get(dep, ""))
    tool = TOOLS.get(task.tool)
    try:
        return await tool(text) if tool else f"error: unknown tool {task.tool}"
    except Exception as exc:
        return f"error: {exc}"


async def schedule(tasks: list[Task], results: dict[int, str]) -> None:
    # plain code: a task starts when all the tasks it depends on have a result
    while waiting := [t for t in tasks if t.id not in results]:
        ready = [t for t in waiting if all(d in results for d in t.depends_on)]
        if not ready:  # a cycle or a missing dependency: stop, do not wait
            results.update({t.id: "not run: a dependency never resolved" for t in waiting})
            return
        outputs = await asyncio.gather(*(call(t, results) for t in ready))  # ready tasks run together
        results.update({t.id: out for t, out in zip(ready, outputs)})


async def run(task: str) -> dict:
    tasks: list[Task] = []
    results: dict[int, str] = {}  # with the tasks, this is the graph store
    plans, missing = 0, ""
    while True:
        log = "\n".join(f"{t.id}. {t.tool}[{t.input}] -> {results[t.id]}" for t in tasks)
        prompt = f"Task: {task}\nTools: {', '.join(TOOLS)}"
        if plans:
            prompt += f"\n\nCalls so far:\n{log}\n\nStill missing: {missing}"
        new = (await Runner.run(planner, prompt)).final_output_as(Graph)
        plans += 1
        known = {t.id for t in tasks}
        tasks += [t for t in new.tasks if t.id not in known][: MAX_TASKS - len(known)]
        await schedule(tasks, results)
        last = plans > MAX_REPLANS or len(tasks) >= MAX_TASKS
        log = "\n".join(f"{t.id}. {t.tool}[{t.input}] -> {results[t.id]}" for t in tasks)
        ask = f"Task: {task}\n\nCalls and results:\n{log}"
        if last:
            ask += "\n\nNo replan is left. Answer now and say what is still unknown."
        join = (await Runner.run(joiner, ask)).final_output_as(Join)
        if join.action == "answer" or last:
            ran = [{**t.model_dump(), "result": results[t.id]} for t in tasks]
            return {"answer": join.text, "tasks": ran, "plans": plans}
        missing = join.text

Neither agent holds the tools: the planner names them and your scheduler calls them. It works in waves; the paper's unit starts each task as soon as it is ready.

Vercel AI SDK, typescript, package ai
import { anthropic } from '@ai-sdk/anthropic';
import { Output, ToolLoopAgent } from 'ai';
import { z } from 'zod';

const MAX_REPLANS = 2;
const MAX_TASKS = 12;
const model = anthropic('claude-sonnet-5-5');

// stubs: plug in your systems; these must be safe to run together
const TOOLS: Record<string, (input: string) => Promise<string>> = {
  crm: async (query) => `stub: CRM record for ${query}`,
  billing: async (customer) => `stub: invoices for ${customer}`,
  support: async (customer) => `stub: open tickets for ${customer}`,
};

const taskSchema = z.object({
  id: z.number().int(),
  tool: z.string(),
  input: z.string().describe('may contain $1, $2: results of the tasks it depends on'),
  dependsOn: z.array(z.number().int()),
});
type Task = z.infer<typeof taskSchema>;

const planner = new ToolLoopAgent({
  model,
  instructions:
    'Break the task into tool calls. Give each a number, one tool, its input and the numbers of the calls ' +
    'whose results it needs. Write $1 where the result of call 1 goes. List a dependency only when the ' +
    'result is needed. On a replan, keep the numbering going and add only what is missing.',
  output: Output.object({ schema: z.object({ tasks: z.array(taskSchema) }) }),
});

const joiner = new ToolLoopAgent({
  model,
  instructions:
    'Read the task and every result. If they are enough, write the final answer. If not, ask for a new ' +
    'plan and say in one line what is missing. If no replan is left, answer and say what is unknown.',
  output: Output.object({
    schema: z.object({ action: z.enum(['answer', 'replan']), text: z.string().describe('the answer, or what is missing') }),
  }),
});

async function call(task: Task, results: Map<number, string>): Promise<string> {
  let text = task.input;
  for (const dep of [...task.dependsOn].sort((a, b) => b - a)) {
    text = text.split('$' + dep).join(results.get(dep) ?? '');
  }
  const tool = TOOLS[task.tool];
  try {
    return tool ? await tool(text) : `error: unknown tool ${task.tool}`;
  } catch (err) {
    return `error: ${String(err)}`;
  }
}

// plain code: a task starts when all the tasks it depends on have a result
async function schedule(tasks: Task[], results: Map<number, string>) {
  for (;;) {
    const waiting = tasks.filter((t) => !results.has(t.id));
    if (waiting.length === 0) return;
    const ready = waiting.filter((t) => t.dependsOn.every((d) => results.has(d)));
    if (ready.length === 0) { // a cycle or a missing dependency: stop, do not wait
      for (const t of waiting) results.set(t.id, 'not run: a dependency never resolved');
      return;
    }
    const outputs = await Promise.all(ready.map((t) => call(t, results))); // ready tasks run together
    ready.forEach((t, i) => results.set(t.id, outputs[i]));
  }
}

export async function run(task: string) {
  const tasks: Task[] = [];
  const results = new Map<number, string>(); // with the tasks, this is the graph store
  const log = () => tasks.map((t) => `${t.id}. ${t.tool}[${t.input}] -> ${results.get(t.id)}`).join('\n');
  let missing = '';
  for (let plans = 1; ; plans++) {
    let prompt = `Task: ${task}\nTools: ${Object.keys(TOOLS).join(', ')}`;
    if (plans > 1) prompt += `\n\nCalls so far:\n${log()}\n\nStill missing: ${missing}`;
    const { output: graph } = await planner.generate({ prompt });
    const fresh = graph.tasks.filter((t) => !tasks.some((k) => k.id === t.id));
    tasks.push(...fresh.slice(0, MAX_TASKS - tasks.length));
    await schedule(tasks, results);
    const last = plans > MAX_REPLANS || tasks.length >= MAX_TASKS;
    let ask = `Task: ${task}\n\nCalls and results:\n${log()}`;
    if (last) ask += '\n\nNo replan is left. Answer now and say what is still unknown.';
    const { output: join } = await joiner.generate({ prompt: ask });
    if (join.action === 'answer' || last) {
      return { answer: join.text, tasks: tasks.map((t) => ({ ...t, result: results.get(t.id) })), plans };
    }
    missing = join.text;
  }
}

The scheduler runs in waves with Promise.all. The paper's unit starts each task the moment its inputs are ready, even while the plan is still streaming.

Snippets are generated when the site is built and type-checked against the SDK versions listed in the repository. Treat them as a starting skeleton.

What goes wrong

  • A planner that lists every earlier task as a dependency turns the graph into a chain. Ask it to list a dependency only when the result is used.
  • Two calls that write to the same record do not depend on each other and still conflict. Run tools with side effects one at a time.
  • A cycle or a missing dependency leaves tasks that never become ready. The scheduler must detect this and stop, not wait.
  • A joiner that asks for a new plan after every round makes this a slow step-by-step loop. Cap the replans.

Chain it

Its result can feed

Source