Plan tool¶
make_planner is a pre-built factory that wires up an LLM-driven
planner: it picks between a direct sub-agent call or a multi-step
plan automatically, based on the input. Use it as the orchestrator
when you want planning logic without writing it from scratch.
Canonical name:
make_planneris a backward-compat alias fororchestrator_agent(inlazybridge.ext.planners). New code can use either; the alias signals "this orchestrates sub-agents", the canonical name distinguishes fromlazybridge.Plan(the static DAG engine) since both involve "planning".
Source¶
"""Demo: ``lazybridge.ext.planners.make_planner`` with three sub-agents.
The factory itself lives in :mod:`lazybridge.ext.planners.builder` — this file
just shows a minimal usage pattern. Run it with provider credentials in
the environment to see the planner pick between direct sub-agent calls
and ``execute_plan`` for multi-step work.
"""
from lazybridge import Agent, LLMEngine
from lazybridge.ext.planners import make_planner
def web_search(query: str) -> str:
"""Look up current facts (stub — wire to a real search API)."""
return f"[stub web result for {query!r}]"
def add(a: float, b: float) -> float:
"""Add two numbers."""
return a + b
def multiply(a: float, b: float) -> float:
"""Multiply two numbers."""
return a * b
def main() -> None:
research = Agent(
engine=LLMEngine("claude-haiku-4-5", system="Look up facts via web_search."),
tools=[web_search],
name="research",
description="Web lookups for current facts. No math.",
)
math = Agent(
engine=LLMEngine("claude-haiku-4-5", system="Solve arithmetic with add/multiply."),
tools=[add, multiply],
name="math",
description="Arithmetic (add, multiply). No facts.",
)
writer = Agent(
engine=LLMEngine("claude-haiku-4-5", system="Synthesise prior results into prose."),
name="writer",
description="Turns prior results into a short paragraph.",
)
planner = make_planner([research, math, writer], verbose=True)
queries = [
"What does FAANG stand for?", # trivial
"What is 17 * 23 + 5?", # one agent
"Research quantum networking and write a one-paragraph brief.", # multi-step plan
"Look up the FAANG headcounts in parallel and write a summary.", # parallel band + N-branch synth
]
for q in queries:
print(f"\n>>> {q}")
print(planner(q).text())
if __name__ == "__main__":
main()
Walkthrough¶
make_planner([research, math, writer])returns anAgent. The factory underlazybridge.ext.planners.builderconstructs an innerPlan+ dispatch logic; you supply the specialists.- Specialist
description=drives the planner's choice of which agent to call; precise descriptions matter as much as for the supervisor pattern. - Four query styles exercise the planner's decision tree: trivial (no agent needed), single-agent (one specialist), multi-step plan (chained calls), parallel + synth (fan-out then combine).
Variations¶
- Use
make_blackboard_planner(see Blackboard planner) for a flat to-do list shape instead of a DAG. - For full control over the planning shape, build the
Planyourself — see Agent builds a plan and Dynamic re-planning. - The factory accepts
verbose=Trueto surface planner decisions on stdout; pair with aSessionfor structured event logs.
See also¶
- Plan — the engine the factory wraps.
- Blackboard planner — sibling factory for flat task lists.
- Agent builds a plan — the manual alternative when you want to write the planning logic yourself.