You have one brief — a paragraph describing the week's work. You want events extracted and tasks extracted from the same text. What is the clean way?
Two separate functions? Or one agent that returns both in a Pydantic shape?
Two specialized agents, one shared input. Each agent stays narrow; the orchestrator merges both outputs into one dict. The two extractors:
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
events = events_agent.run_sync(brief).output
tasks = tasks_agent.run_sync(brief).outputSame brief input goes into both — parallel calls, different roles, the results get combined at the end?
Exactly. The brief is the shared state; each agent reads its own slice. The orchestrator returns one dict holding both lists plus the original brief for traceability:
def orchestrate_calendar_and_tasks(brief: str) -> dict:
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
out = {
"brief": brief,
"events": events_agent.run_sync(brief).output,
"tasks": tasks_agent.run_sync(brief).output,
}
return outWhy include the brief in the returned dict? The caller already has it.
For traceability. When this dict lands in a log, a test, or a downstream system, the brief it came from is attached. Debugging becomes trivial — you see the input and both outputs together without chasing a separate variable.
So one shared context drives two specialized agents and comes back as a clean dict with everything the caller needs?
One input, two roles, one traceable output. This is the shape of every multi-agent orchestration — independent specialists sharing state through a plain Python value.
TL;DR: run two narrow list[str] agents over the same brief; return both lists plus the brief.
system_prompt per agent — one extractor per responsibility| Single agent | Two agents |
|---|---|
| Mixed prompt | Narrow roles |
| Harder to tune | Easy to adjust one |
Specialist agents sharing one context produce cleaner, more reliable results than one agent asked to juggle two jobs.
You have one brief — a paragraph describing the week's work. You want events extracted and tasks extracted from the same text. What is the clean way?
Two separate functions? Or one agent that returns both in a Pydantic shape?
Two specialized agents, one shared input. Each agent stays narrow; the orchestrator merges both outputs into one dict. The two extractors:
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
events = events_agent.run_sync(brief).output
tasks = tasks_agent.run_sync(brief).outputSame brief input goes into both — parallel calls, different roles, the results get combined at the end?
Exactly. The brief is the shared state; each agent reads its own slice. The orchestrator returns one dict holding both lists plus the original brief for traceability:
def orchestrate_calendar_and_tasks(brief: str) -> dict:
events_agent = Agent(model, result_type=list[str], system_prompt="Extract calendar events as short phrases.")
tasks_agent = Agent(model, result_type=list[str], system_prompt="Extract action items as short tasks.")
out = {
"brief": brief,
"events": events_agent.run_sync(brief).output,
"tasks": tasks_agent.run_sync(brief).output,
}
return outWhy include the brief in the returned dict? The caller already has it.
For traceability. When this dict lands in a log, a test, or a downstream system, the brief it came from is attached. Debugging becomes trivial — you see the input and both outputs together without chasing a separate variable.
So one shared context drives two specialized agents and comes back as a clean dict with everything the caller needs?
One input, two roles, one traceable output. This is the shape of every multi-agent orchestration — independent specialists sharing state through a plain Python value.
TL;DR: run two narrow list[str] agents over the same brief; return both lists plus the brief.
system_prompt per agent — one extractor per responsibility| Single agent | Two agents |
|---|---|
| Mixed prompt | Narrow roles |
| Harder to tune | Easy to adjust one |
Specialist agents sharing one context produce cleaner, more reliable results than one agent asked to juggle two jobs.
Create a free account to get started. Paid plans unlock all tracks.