forked from conductor-oss/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07_parallel_agents.py
More file actions
70 lines (56 loc) · 2.35 KB
/
Copy path07_parallel_agents.py
File metadata and controls
70 lines (56 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (c) 2025 Agentspan
# Licensed under the MIT License. See LICENSE file in the project root for details.
"""Parallel Agents — fan-out / fan-in.
Demonstrates the parallel strategy where all sub-agents run concurrently
on the same input and their results are aggregated.
Requirements:
- Conductor server with LLM support
- AGENTSPAN_SERVER_URL=http://localhost:8080/api as environment variable
- AGENTSPAN_LLM_MODEL=openai/gpt-4o-mini as environment variable
"""
from conductor.ai.agents import Agent, AgentRuntime, Strategy
from settings import settings
# ── Specialist analysts ─────────────────────────────────────────────
market_analyst = Agent(
name="market_analyst",
model=settings.llm_model,
instructions=(
"You are a market analyst. Analyze the given topic from a market perspective: "
"market size, growth trends, key players, and opportunities."
),
)
risk_analyst = Agent(
name="risk_analyst",
model=settings.llm_model,
instructions=(
"You are a risk analyst. Analyze the given topic for risks: "
"regulatory risks, technical risks, competitive threats, and mitigation strategies."
),
)
compliance_checker = Agent(
name="compliance",
model=settings.llm_model,
instructions=(
"You are a compliance specialist. Check the given topic for compliance considerations: "
"data privacy, regulatory requirements, and industry standards."
),
)
# ── Parallel analysis ───────────────────────────────────────────────
analysis = Agent(
name="analysis",
model=settings.llm_model,
agents=[market_analyst, risk_analyst, compliance_checker],
strategy=Strategy.PARALLEL,
)
if __name__ == "__main__":
with AgentRuntime() as runtime:
result = runtime.run(analysis, "Launching an AI-powered healthcare diagnostic tool in the US market")
result.print_result()
# Production pattern:
# 1. Deploy once during CI/CD:
# runtime.deploy(analysis)
# CLI alternative:
# agentspan deploy --package examples.07_parallel_agents
#
# 2. In a separate long-lived worker process:
# runtime.serve(analysis)