Repository navigation
Closed
Labels
agentsAgent frameworkenhancementNew feature or requestresearchResearch, methodology, ablationsv2.0.1Planned for v2.0.1 release
Milestone
Description
Summary
Extend AgentFederation so agents negotiate roles dynamically via an internal market: each agent bids on incoming tasks based on its historical cost/quality from CostQualityRouter. Roles emerge from the market, not from hardcoded orchestration graphs.
Motivation
Today's multi-agent frameworks (CrewAI, AutoGen, our own AgentFederation) require humans to pre-assign roles. This is brittle: as the agent fleet grows, role assignments become stale. A market mechanism self-organizes the team and naturally exploits the strongest specialist for each task.
Design Sketch
from synapsekit import AgentSwarm, MarketPolicy, BidStrategy
swarm = AgentSwarm(
agents=[researcher, coder, critic, planner, summarizer, ...],
market=MarketPolicy(
bid_strategy=BidStrategy.cost_quality_pareto(),
auction_type=\"sealed_bid\",
budget_per_task=10_000, # tokens
learning_rate=0.1, # how fast agents update bids from outcomes
),
registry=AgentRegistry.redis(\"redis://...\"),
)
result = await swarm.execute(\"Write a market analysis on quantum compute startups\")
# Swarm dynamically assembles: planner -> 3 researchers -> critic -> summarizer
# Bids logged. Winners' bid models update from final reward.Mechanism
- Task broadcast — task posted to swarm with budget
- Bid — each agent submits (estimated_cost, estimated_quality, confidence) using its own
CostQualityRouterhistory - Auction —
MarketPolicyselects winner(s) — supports single-winner, multi-winner (parallel), and coalition (cooperative) modes - Execute — winner runs, emits result + actual cost
- Settle — actual reward updates each agent's bid model (online learning)
- Reputation —
AgentRegistrytracks per-agent track record per task category
Components
-
AgentSwarmorchestrator -
MarketPolicy(auction types: sealed-bid, English, Vickrey) -
BidStrategyinterface (cost-quality, Thompson sampling, UCB) -
AgentBiddermixin — adds.bid(task) -> Bidto any agent -
Reputationstore — Redis-backed, per-(agent, task_category) Bayesian posterior -
CoalitionFormer— agents bid as teams for tasks beyond any single agent - Visualization:
swarm.trace_to_mermaid()— show which agent won which sub-task
Use Cases
- Heterogeneous fleets (GPT-4o + Claude Opus + local Llama) where each excels at different things
- Cost-bounded research where the market routes to the cheapest sufficient agent
- Emergent specialization: agents that consistently win "code review" tasks become the de-facto reviewers without being labeled as such
Risks
- Cold start — new agents have no bid history. Mitigate with optimistic priors + epsilon-greedy exploration.
- Collusion / runaway bidding — bound bids to budget; cap concentration (no single agent > 70% of tasks).
- Cost of the auction itself — keep bid evaluation O(N), cache reputation lookups
Acceptance Criteria
- Demo: 5-agent swarm outperforms hardcoded
AgentFederationon a 100-task benchmark by ≥15% - Cost reduction ≥25% vs. always-route-to-best-model baseline
- Live dashboard via
PrometheusMetrics: bids/sec, win rate per agent, avg reward - Determinism mode for testing (
market.seed=42) - Replayable role-allocation receipt (h/t @clementineCU) — every auction emits an
AgentSwarmReceiptthat can be replayed without trusting the final answer, built in two phases so the reputation prior is never overwritten before it's recorded:- Auction-time fields (captured before
record_outcome()runs):task_id, candidate agent ids, bid inputs each agent was allowed to see, reputation prior version (the exact snapshot bids were scored against), selected role, rejected roles, budget allocated. - Settlement-time fields (captured after execution): budget consumed,
outcome_score_source(external_overridevs.self_reported— collapsed to a two-way grounded/ungrounded split, since agent-returned output fields aren't meaningfully more trustworthy than the bid's own estimate), andlearning_rule_version. - Grounding is tracked, not silently trusted: a winning agent's own
estimated_quality/output-reported quality may appear in the receipt as evidence, but theReputationSnapshotit produces is taggedgrounded=Falseunless an externally-supplied reward/quality override was passed toexecute(). Ungrounded updates still persist (preserves online learning with no external judge wired up) but are discounted/filterable downstream. Hard-refusing ungrounded updates is opt-in viaMarketPolicy.require_grounded_reward=True, not the default. - Spec test:
tests/agents/test_agent_swarm_receipt.py::test_auction_receipt_is_replayable_without_trusting_final_answer(currentlyxfail; extend with the grounded/ungrounded invariant before removing the marker).
- Auction-time fields (captured before
Related
- Extends
AgentFederation+AgentRegistry(feat: distributed agent registry and federation #718) - Uses
CostQualityRouterlearning signal
Metadata
Metadata
Assignees
Labels
agentsAgent frameworkenhancementNew feature or requestresearchResearch, methodology, ablationsv2.0.1Planned for v2.0.1 release
Activity
clementineCU commentedon Jul 18, 2026
One acceptance test I would add: every auction should emit a role-allocation receipt that can be replayed without trusting the final answer.
Minimum fields: task_id, candidate agents, bid inputs each agent was allowed to see, cost/quality prior version, bid value, selected role, rejected roles, budget consumed, outcome score source, and the rule that updates future bids.
That keeps emergent specialization inspectable. If an agent wins because the learning rule drifted, a reviewer can see whether the market learned from a real outcome or just reinforced a stale/self-reported score.
AmitoVrito commentedon Jul 18, 2026
Status update (2026-07-18) — retargeted to v2.0.1
Same picture as #735: the mechanism is fully built, not unstarted.
Done
AgentSwarmorchestrator,MarketPolicy,BidStrategy,AuctionType,AgentBidderprotocolCoalitionFormer(cooperative bidding, deterministic combo selection)Reputationstore (in-memory) +RedisReputation— both implemented inagent_registry.py, matchesAgentFederation/AgentRegistry(feat: distributed agent registry and federation #718) patternMarketPolicy.seedwired through torandom.Random(seed)swarm.trace_to_mermaid()visualizationexamples/agent_swarm_market.pydemotests/agents/test_agent_swarm_market.pyRemaining
AgentFederation— no benchmark harness exists proving the swarm beats hardcoded orchestration by ≥15%. This is the acceptance criterion with zero code against it.PrometheusMetricsdashboard (bids/sec, win rate per agent, avg reward) — no wiring betweenAgentSwarm/ReputationandPrometheusMetricsyet; greppedobservability/and found nothing referencing swarm.Net: like #735, this is a benchmark + observability-wiring PR, not a from-scratch build. The market mechanism itself (auction, bidding, coalition, reputation, Redis backend) is done and tested.
AmitoVrito commentedon Jul 18, 2026
@clementineCU this is a valid and important gap — thanks for flagging it.
I checked the code: it's not just theoretical.
_actual_quality()(agent_swarm.py) falls back to the winning agent's ownestimated_qualityfrom its bid when no external quality/reward is supplied at execute time — so today the reputation store can update purely from an agent grading its own bid, with no external grounding. That's exactly the "market learned from a real outcome vs. reinforced a stale/self-reported score" risk you're describing.Added it as an acceptance criterion above, and wrote a spec test (
tests/agents/test_agent_swarm_receipt.py, currentlyxfailsince the receipt fields don't exist yet) capturing the minimum fields you listed: task_id, candidate agents, bid inputs, reputation prior version, selected/rejected roles, budget consumed, outcome score source, and the learning rule version.Would you like to take this one?
AmitoVrito commentedon Jul 18, 2026
Spec test committed:
tests/agents/test_agent_swarm_receipt.py(commit e772e8c, xfail pending implementation). Acceptance criteria list above is up to date.clementineCU commentedon Jul 18, 2026
Thanks for turning it into a spec test. I would keep this as a maintainer-owned implementation, but the clean shape I would use is:
That gives reviewers the thing the market needs most: not just "who won", but whether the market learned from an external outcome or from its own stale prior.
test(agents): add spec test for replayable AgentSwarm auction receipt
AmitoVrito commentedon Jul 18, 2026
@clementineCU makes sense, and it's aligned with the direction — a few responses:
Agreed, and this is more than style — it's a correctness fix: building the receipt at the auction boundary, before
record_outcome()runs, isn't optional. Checked the code again:_score_bids()readsreputation.get(...)at auction time, thenrecord_outcome()later mutates that same store. If the receipt were assembled after settlement,reputation_priorwould show the post-update snapshot, not the one bids were actually scored against. So in practice the receipt needs two write points, not one atomic emission: auction-time (candidates, bids, prior, selected/rejected roles, budget allocated) and settlement-time (budget consumed, outcome_score_source, actual reward) — same fields you listed, just acknowledging they land at different moments.Agreed on the field list — matches what's already in the acceptance criteria and the xfail test.
Pushback on refuse/no-op as the default: I'd split "label as degraded" (yes, unconditionally) from "block the reputation update" (not by default). The issue's own design sketch wants online learning without requiring an external judge for every task — most callers won't wire up independent grading, so hard-refusing self-reported outcomes by default means the swarm mostly never learns, which undercuts the emergent-specialization pitch. Proposal instead: always persist the update, but tag the
ReputationSnapshotwithgrounded=Falseprovenance so it can be discounted, filtered, or weighted down by a stricter learning rule downstream. Hard refusal becomes an opt-inMarketPolicy.require_grounded_reward=Truefor audited/regulated deployments, not global default behavior.One addition to your source taxonomy: "extracted from output" isn't necessarily more trustworthy than the bid fallback — it's still the same agent self-reporting a
quality/scorekey in its own return value, just at finer granularity. Nothing stops an agent from always returning{"quality": 1.0}. Only an explicit caller-supplied override (independent eval/judge) is actually externally grounded. Worth being precise that it's a two-way split (grounded vs. self-reported), not three tiers of decreasing trust.Agreed on the test invariant — will extend the xfail test so a winning agent's own
estimated_qualitycan appear in the receipt as evidence but can never advance reputation asgrounded=Trueon its own.Since you're not taking implementation, I'll own it — will fold this into the receipt spec (two-phase emission,
groundedflag, opt-in strict mode) before scoping the actual PR.Merge pull request #873 from SynapseKit/feat/agent-swarm-benchmark-734
feat(provenance): add GroundedSignal primitive + AgentSwarm replayabl…
test(agents): AgentSwarm market-routing acceptance gate (SynapseKit#734)