Skip to content

Commit 2e258df

Browse files
committed
[feat][round-robin-rewrite][replace shuffle with true round robin][feat][turn-awareness][add prev next speaker context][improvement][verbose-logging][gate logs behind verbose flag][improvement][remove-tenacity][drop retry decorator from round robin][improvement][drop-callback][delete unused callback hook][improvement][prompt-extract][move prompts to module functions][improvement][init-validation][consolidate agents check in init][feat][rr-examples][add round robin examples folder][feat][investment-committee][add etf committee example][feat][tumor-board][add medical treatment review example][feat][design-review][add engineering design review example][improvement][unify-imports][use top level swarms import in examples][improvement][version-bump][bump version to 12 0 2]
1 parent 6f98a5f commit 2e258df

7 files changed

Lines changed: 430 additions & 90 deletions

File tree

commit_message.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[feat][round-robin-rewrite][replace shuffle with true round robin][feat][turn-awareness][add prev next speaker context][improvement][verbose-logging][gate logs behind verbose flag][improvement][remove-tenacity][drop retry decorator from round robin][improvement][drop-callback][delete unused callback hook][improvement][prompt-extract][move prompts to module functions][improvement][init-validation][consolidate agents check in init][feat][rr-examples][add round robin examples folder][feat][investment-committee][add etf committee example][feat][tumor-board][add medical treatment review example][feat][design-review][add engineering design review example][improvement][unify-imports][use top level swarms import in examples][improvement][version-bump][bump version to 12 0 2]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""
2+
Engineering design review: four engineers rotate through a proposed system
3+
design and refine it across two passes.
4+
5+
The architect opens with the proposal, the SRE attacks operability, the
6+
security engineer surfaces threat model gaps, and the staff engineer
7+
adjudicates trade-offs. Loop 2 lets each role respond to the others'
8+
critiques.
9+
"""
10+
11+
from swarms import Agent, RoundRobinSwarm
12+
13+
architect = Agent(
14+
agent_name="Architect",
15+
agent_description="Proposes and defends the system design.",
16+
system_prompt=(
17+
"You are the proposing architect. State the design crisply: "
18+
"components, data flow, key APIs, and the failure modes you "
19+
"are willing to accept. In loop 2, revise based on the critique "
20+
"you received."
21+
),
22+
model_name="gpt-4.1",
23+
max_loops=1,
24+
)
25+
26+
sre = Agent(
27+
agent_name="SRE",
28+
agent_description="Site reliability engineer.",
29+
system_prompt=(
30+
"You are an SRE. Stress-test the proposal on operability: SLOs, "
31+
"blast radius of failures, rollback story, observability gaps, "
32+
"and on-call burden. Give specific, actionable pushback."
33+
),
34+
model_name="gpt-4.1",
35+
max_loops=1,
36+
)
37+
38+
security = Agent(
39+
agent_name="SecurityEngineer",
40+
agent_description="Application security engineer.",
41+
system_prompt=(
42+
"You are a security engineer. Walk the threat model: auth, "
43+
"authz, data exposure, supply chain, and trust boundaries. "
44+
"Name at least one concrete attack the prior speakers missed."
45+
),
46+
model_name="gpt-4.1",
47+
max_loops=1,
48+
)
49+
50+
staff_engineer = Agent(
51+
agent_name="StaffEngineer",
52+
agent_description="Senior IC arbitrating trade-offs.",
53+
system_prompt=(
54+
"You are a staff engineer. Adjudicate: which critiques are "
55+
"blocking, which are nice-to-have, and what is the smallest "
56+
"change to the design that addresses the blocking ones. End "
57+
"your turn with a clear ship / iterate / reject verdict."
58+
),
59+
model_name="gpt-4.1",
60+
max_loops=1,
61+
)
62+
63+
review = RoundRobinSwarm(
64+
name="System-Design-Review",
65+
agents=[architect, sre, security, staff_engineer],
66+
max_loops=2,
67+
output_type="all",
68+
verbose=True,
69+
)
70+
71+
proposal = (
72+
"Proposal: replace our monolithic order-processing service with an "
73+
"event-driven architecture. Orders are published to a Kafka topic, "
74+
"consumed by three independent services (inventory, payments, "
75+
"fulfilment), each with their own Postgres database. A new GraphQL "
76+
"gateway aggregates state for the UI. Target: 10x throughput, "
77+
"independent deploys per service. We have 6 engineers and 8 weeks."
78+
)
79+
80+
result = review.run(proposal)
81+
print(result)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
Investment-committee roundtable on whether to launch a thematic AI ETF.
3+
4+
Four committee members rotate in fixed order across two full loops, so each
5+
member gets two turns. Each turn, the speaker sees the full transcript so
6+
far plus who spoke before them and who is up next, which is what makes the
7+
round-robin (rather than parallel) structure useful here: later speakers
8+
can directly respond to the prior speaker's case.
9+
"""
10+
11+
from swarms import Agent, RoundRobinSwarm
12+
13+
cio = Agent(
14+
agent_name="CIO",
15+
agent_description="Chief Investment Officer.",
16+
system_prompt=(
17+
"You are the Chief Investment Officer. Lead with the strategic "
18+
"case: market fit, expected AUM, and how the product slots into "
19+
"the existing lineup. Be concrete about target investors."
20+
),
21+
model_name="gpt-4.1",
22+
max_loops=1,
23+
)
24+
25+
risk_officer = Agent(
26+
agent_name="RiskOfficer",
27+
agent_description="Head of risk management.",
28+
system_prompt=(
29+
"You are the Head of Risk. Stress-test the prior speaker's "
30+
"argument: concentration risk, drawdown scenarios in an AI "
31+
"selloff, tracking error, liquidity of the underlying basket. "
32+
"Quantify wherever possible."
33+
),
34+
model_name="gpt-4.1",
35+
max_loops=1,
36+
)
37+
38+
allocation_strategist = Agent(
39+
agent_name="AllocationStrategist",
40+
agent_description="Portfolio construction lead.",
41+
system_prompt=(
42+
"You are the Allocation Strategist. Propose the index "
43+
"methodology: weighting scheme, rebalance cadence, inclusion "
44+
"criteria, and how it differs from existing thematic ETFs in "
45+
"the market."
46+
),
47+
model_name="gpt-4.1",
48+
max_loops=1,
49+
)
50+
51+
compliance = Agent(
52+
agent_name="Compliance",
53+
agent_description="Compliance and regulatory counsel.",
54+
system_prompt=(
55+
"You are Compliance. Flag any regulatory, disclosure, or "
56+
"naming-rule concerns (e.g. SEC Names Rule 35d-1). State what "
57+
"must be true for the product to be approved."
58+
),
59+
model_name="gpt-4.1",
60+
max_loops=1,
61+
)
62+
63+
committee = RoundRobinSwarm(
64+
name="AI-ETF-Investment-Committee",
65+
agents=[cio, risk_officer, allocation_strategist, compliance],
66+
max_loops=2,
67+
output_type="all",
68+
verbose=True,
69+
)
70+
71+
result = committee.run(
72+
"Should we launch a new thematic ETF targeting the AI infrastructure "
73+
"supply chain (chips, datacenter REITs, power/cooling, networking)? "
74+
"Reach a recommendation."
75+
)
76+
77+
print(result)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""
2+
Tumor-board style roundtable: three specialists deliberate on a treatment
3+
plan for a single patient case.
4+
5+
Each specialist contributes their perspective in fixed order, then the cycle
6+
repeats so each gets to react to what the others said. This is a
7+
discussion-aid demo only — not medical advice.
8+
"""
9+
10+
from swarms import Agent, RoundRobinSwarm
11+
12+
oncologist = Agent(
13+
agent_name="MedicalOncologist",
14+
agent_description="Medical oncology lead.",
15+
system_prompt=(
16+
"You are a medical oncologist. Frame the systemic-therapy "
17+
"options (chemo, targeted, immunotherapy), expected response "
18+
"rates for the staging given, and contraindications. Be precise "
19+
"about which regimens you would consider first-line."
20+
),
21+
model_name="gpt-4.1",
22+
max_loops=1,
23+
)
24+
25+
surgeon = Agent(
26+
agent_name="SurgicalOncologist",
27+
agent_description="Surgical oncology specialist.",
28+
system_prompt=(
29+
"You are a surgical oncologist. Evaluate whether the case is "
30+
"resectable, the morbidity of the surgical option, and how "
31+
"surgery sequences with the systemic plan the prior speaker "
32+
"proposed (neoadjuvant vs adjuvant)."
33+
),
34+
model_name="gpt-4.1",
35+
max_loops=1,
36+
)
37+
38+
palliative = Agent(
39+
agent_name="PalliativeCare",
40+
agent_description="Palliative care and quality-of-life lead.",
41+
system_prompt=(
42+
"You are the palliative care lead. Center the patient's "
43+
"goals-of-care, performance status, and symptom burden. Push "
44+
"back if the proposed plan trades quality of life for marginal "
45+
"survival benefit. Suggest concrete symptom-management additions."
46+
),
47+
model_name="gpt-4.1",
48+
max_loops=1,
49+
)
50+
51+
tumor_board = RoundRobinSwarm(
52+
name="Tumor-Board-Roundtable",
53+
agents=[oncologist, surgeon, palliative],
54+
max_loops=2,
55+
output_type="all",
56+
verbose=True,
57+
)
58+
59+
case = (
60+
"Case: 68-year-old, ECOG 1, newly diagnosed stage IIIA non-small-cell "
61+
"lung adenocarcinoma, EGFR exon 19 deletion. Tumor 4.5 cm, single "
62+
"ipsilateral mediastinal node positive. No comorbidities of note. "
63+
"Patient prioritizes time at home with family. "
64+
"Question: recommend a treatment sequence and explain the trade-offs."
65+
)
66+
67+
result = tumor_board.run(case)
68+
print(result)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from swarms import Agent, RoundRobinSwarm
2+
3+
# Three specialists. RoundRobinSwarm will visit them in this exact order
4+
# every loop: Optimist -> Skeptic -> Synthesiser -> Optimist -> ...
5+
# Each agent reads the full transcript so far and knows who spoke before
6+
# it and who is up next (injected into the prompt automatically).
7+
8+
optimist = Agent(
9+
agent_name="Optimist",
10+
agent_description="Argues for the upside of the proposal.",
11+
system_prompt=(
12+
"You are an optimist. Your job is to identify the strongest "
13+
"reasons the proposal under discussion will succeed. Be specific."
14+
),
15+
model_name="gpt-4.1",
16+
max_loops=1,
17+
)
18+
19+
skeptic = Agent(
20+
agent_name="Skeptic",
21+
agent_description="Stress-tests claims and surfaces risks.",
22+
system_prompt=(
23+
"You are a skeptic. Your job is to challenge the previous "
24+
"speaker's strongest claim with a concrete failure mode or "
25+
"missing assumption."
26+
),
27+
model_name="gpt-4.1",
28+
max_loops=1,
29+
)
30+
31+
synthesiser = Agent(
32+
agent_name="Synthesiser",
33+
agent_description="Distils the discussion into a working position.",
34+
system_prompt=(
35+
"You are a synthesiser. Reconcile the optimist's case and the "
36+
"skeptic's pushback into one clear recommendation."
37+
),
38+
model_name="gpt-4.1",
39+
max_loops=1,
40+
)
41+
42+
swarm = RoundRobinSwarm(
43+
name="Decision-Roundtable",
44+
agents=[optimist, skeptic, synthesiser],
45+
max_loops=1, # two full cycles → 6 turns total
46+
output_type="all",
47+
)
48+
49+
result = swarm.run(
50+
"Should a 30-person Series A startup build their own LLM "
51+
"fine-tuning pipeline or rent one from a vendor?"
52+
)
53+
54+
print(result)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
77
name = "swarms"
8-
version = "12.0.1"
8+
version = "12.0.2"
99
description = "Swarms - TGSC"
1010
license = "Apache-2.0"
1111
authors = ["Kye Gomez <kye@swarms.world>"]

0 commit comments

Comments
 (0)