datamongus
10/28/2025, 5:21 PMMarvin
10/28/2025, 5:21 PMMarvin
10/28/2025, 5:27 PMfrom marvin import Agent, Team
# Specialists
researcher = Agent(
name="Researcher",
instructions=(
"Research the topic, return concise bullet facts and relevant links. "
"Avoid long prose."
),
)
writer = Agent(
name="Writer",
instructions=(
"Using provided facts, write a clear, polished response. "
"Be concise and structured."
),
)
# Coordinator that delegates to the specialists
lead = Agent(
name="Lead",
instructions=(
"Break the request into subtasks. Delegate research to Researcher and "
"drafting to Writer. Review and return the final answer."
),
verbose=True, # optional: prints the thought process/events
)
# Team wiring: allow Lead to delegate to Researcher and Writer
team = Team(
members=[lead, researcher, writer],
delegates={lead: [researcher, writer]},
verbose=True, # optional
)
# Kick off the conversation with the team
result = team.say(
"Write a two-paragraph summary of why you'd orchestrate LLM workloads with Prefect."
)
print(result)
What this does:
- You create specialized agents for research and writing.
- A “Lead” agent coordinates and can delegate to allowed members.
- The Team sets the allowed delegation map (delegates={lead: [researcher, writer]}).
- Calling team.say(...) triggers the coordination and agent-to-agent workflow.
Notes and variations:
- For a more free-form collaboration pattern, you can also use Swarm (a team variant) where members can contribute more opportunistically.
- If you want the lead to broadcast context to all agents at once, you can expose marvin.tools.thread.post_message_to_agents as a tool, but in most cases the Team with delegates is the simplest A2A path.
Docs and references:
- Agents concept: Marvin Agents
- Teams concept (delegation, swarms): Marvin Teams
- Multi-step workflow guide: Multi-step workflows
- Engine “end-turn” actions (includes delegate): Engine end_turn API
If by “A2A” you meant something else (e.g., application-to-application auth, or another framework’s A2A), let me know and I’ll tailor an example accordingly.