Inspiration Financial advisors are starting to let AI draft client portfolios. Every client comes with rules: "no single stock above 20%", "no oil companies", "don't trigger a big tax bill". AI drafts break them. A recent study (BiasMix-Finance) found violations in up to 86% of AI first drafts, and in my own tests about 80% of first drafts broke at least one rule. An advisor is a fiduciary and can't send that to a client.

Before this hackathon I built SwarmFolio, a portfolio optimizer based on particle swarm optimization. Its swarm-based feasibility check once called a perfectly feasible set of rules impossible. That's fine for a search heuristic and unacceptable for something whose job is to verify. So the idea behind this project is simple: the verifier, not the AI, is the product.

AI proposes. Math decides.

What it does SwarmFolio Referee is an AI investment committee made of five Fetch.ai agents, which you can talk to in ASI:One:

Three analyst agents (Macro, Fundamentals, Risk) study the market data and each write a memo. A Chair agent turns the memos into a portfolio for the client. A Referee agent checks the portfolio with an exact optimization solver, not an LLM. It reports: which rules broke and by how much, quoted in the client's own words; whether the rules can be met at all, and if not, the smallest set of rules that clash and the cheapest fix; the nearest compliant portfolio, which moves as little money as possible; a reproducible receipt (same inputs → same receipt ID). The analysts read the receipt and concede, defend or modify, and the Chair revises, for up to 3 rounds. If the AI still can't fix it, the Referee repairs it. Rule price tags: the Referee also tells the client what each rule costs. For Mr. Alvarez (a synthetic client), his tax rule costs 4.23 points a year of risk-adjusted return, while his "no energy stocks" rule costs nothing. Example — an impossible client. Dr. Patel must keep ≥ 30% in JNJ (tax reasons) and ≥ 10% in UNH (family shares), but wants healthcare ≤ 35%. The Referee proves no portfolio exists: 30% + 10% = 40% > 35%. It names exactly those three rules and suggests the cheapest fix: raise the healthcare cap to 40%, for the advisor to approve.

Fetch.ai features:

5 uAgents on Agentverse with mailboxes, talking over the Chat Protocol plus a custom committee protocol. ASI:One Interactive Cards: a client picker with "Build portfolio" buttons, the receipt card, the price-tag card. Agent Payment Protocol + Stripe (test mode): the Referee is a standalone service that charges $0.50 per check. You pay right inside ASI:One and the receipt arrives after Stripe confirms. The Chair is our own agent, so it's exempt. Plain-English rules: paste rules as text ("check AAPL 50, JNJ 30, KO 20 against: …") and the Referee reads them, then checks them. Web app: swarmfolio.biz shows every committee run as an audit report (round by round, who changed their mind and why), the printable receipt with its stamp, the impossible-client view, price tags, the experiment, and a Try the Referee sandbox where you can edit any portfolio and check it live. All 26 synthetic clients have a real saved run.

How I built it The Referee (CVXPY + SCIP, no LLM) Ten rule types (single-stock caps and floors, exclusions, sector caps and floors, max/min number of holdings, minimum position size, a volatility cap, a turnover cap), modeled as a mixed-integer second-order cone program. In plain terms:

each stock gets a weight, and the weights add up to 100%;

each stock also gets a yes/no switch ("do we hold it?"). If it's off, the weight must be 0; if it's on, the weight must be at least the minimum position size. These switches make it mixed-integer, and they're what let the solver handle rules like "at least 8 holdings" and "no position under 4%" exactly;

the volatility cap is written using the Cholesky factor of the covariance matrix, which makes it a second-order cone constraint the solver handles exactly.

Repair: the nearest compliant portfolio is an L1 projection: among all portfolios that follow every rule, find the one that moves the least money away from the AI's proposal.

Minimal conflict set: a deletion filter. Drop rules one at a time; if the problem stays infeasible without a rule, that rule wasn't needed. What's left is an irreducible infeasible subset.

Cheapest fix: an elastic program lets every rule bend a little and minimizes the total bend, weighted by each rule's priority. Bending an unimportant rule slightly beats breaking an important one.

Price tags: find the portfolio with the best risk-adjusted return (expected return minus a penalty for risk) under all the rules, then again without each rule. The difference is that rule's price. It's never negative, and zero means the rule doesn't hold the portfolio back.

Stress-tested on 150 random cases with 0 failures, after adding a solver fallback, tolerances for "held" positions, and a small margin so repairs land under a volatility cap rather than 0.001 points over it.

The committee (LangChain) The analysts and the Chair run on Fetch's ASI:One models (asi1-mini for live runs), with a switch to Gemini or Anthropic. Every response is validated with Pydantic, retried once on bad JSON, and cached for reproducible demos. A fresh run bypasses the cache: "Build a fresh portfolio for C04".

The agents (Fetch.ai uAgents → Agentverse → ASI:One) Every agent is a thin wrapper around plain Python functions. The committee loop takes either a local transport or a Fetch transport, so the whole system also runs without the network.

The analysts are asked concurrently. A silent analyst is skipped, and the reply says so. The Referee gets a timeout and a retry, then falls back to the local Referee. uAgents models are Pydantic v1 and ours are v2, so agent messages carry JSON strings. Evaluation 26 synthetic clients, including "hard" clients whose volatility caps sit just above the solver's minimum, and clients with planted conflicts. A paired feedback experiment gives the same first drafts three kinds of feedback (self-check, a bare "rule broken", the Referee's full explanation) for 3 rounds, on two different models:

asi1, 12 trials: 83% of first drafts broke a rule. Compliant after 3 rounds: self-check 33%, bare verdict 42%, Referee's explanation 50%. Gemini 3.5 flash-lite, 20 trials: 80% of first drafts broke a rule. Compliant after 3 rounds: self-check 20%, bare verdict 25%, Referee's explanation 25%. Finding: the AI rarely fixes itself. Explaining the violation helped a little, but it's a trend, not statistically significant (sign test p = 0.63 and p = 1.0). Only the Referee's repair reaches 100%.

Web app and deployment FastAPI + React (Vite, Tailwind), designed in Paper around a "referee's audit" idea: research-report typography, ledger tables, a printable receipt with an ink stamp. The API is on Render, the site on Vercel, the domains on GoDaddy. 293 pytest tests.

Challenges I ran into Proving impossibility reliably. Solver tolerances matter. A stress test found 6 crashes in 60 cases, a false "not held" result at the minimum-position threshold, and a 21-second solve. I fixed them with a solver fallback, a held-position tolerance and a volatility margin. Price tags were slow. Strict tolerances made each utility solve hit the 15 s time limit. Tuning SCIP brought a whole client's price tags down to about a second. Small LLMs make messy JSON. Analysts wrote "TICKER: reason" instead of a ticker list, and the rule reader nested parameters one level too deep. Every LLM output is validated in code, and anything that can't be mapped is reported, never guessed. Agents are slow and sometimes silent. Retrying a timed-out LLM call just runs it twice, so the analysts got their own longer timeout with no retry, and the system says out loud when an agent was skipped. The honest result wasn't the one I hoped for. I expected explained feedback to clearly beat self-checking. It didn't, at least not by a statistically significant margin. I report it as it is. Accomplishments I'm proud of A Referee that can say "no portfolio exists, and here's the 3-rule reason" instead of silently drifting, and can price every rule. A real 5-agent network with Interactive Cards and pay-per-check payments working inside ASI:One. A measured, honestly reported experiment across two models. Shipped: live at swarmfolio.biz (also nicetrychatgpt.biz and aisaidtrustmebro.biz), at my first hackathon, in my first semester. What I learned Keep the creative part (LLMs) and the part that must be right (the solver) separate, and let the right part check the creative part. Prompts are suggestions. Constraints are guarantees. Agent networks need the boring parts: timeouts, fallbacks, and saying when something was skipped. uAgents, Agentverse mailboxes, the Chat Protocol, Interactive Cards and the Agent Payment Protocol. How to direct AI coding tools (Claude Code, Devin) on a real codebase: small steps, tests, and reviewing every change. What's next The Referee as an API for wealthtech platforms and AI-agent builders, priced per verification. PSO searches, the Referee certifies: use SwarmFolio's swarm to explore, and the Referee to prove. More rule types (tax lots, ESG scores, factor exposures) and a larger universe than 19 stocks. Talking to advisors and compliance teams about what a receipt must contain to be trusted. Built at LA Hacks vs. before Before (my open-source SwarmFolio repo, MIT): price download and cached prices for 19 stocks, return and covariance math, a PSO optimizer, a backtest.

Built at LA Hacks: the rule schema; the whole Referee (exact solver, conflict finder, cheapest fix, repair, receipt, price tags, plain-English rules); the analysts, Chair and feedback loop; the 5 Fetch agents; Interactive Cards; payments; 26 synthetic clients; the experiment; the web app and its Paper design; deployment.

Design notes were written before the event. All code was written during it.

Links: Live site · GitHub · Agentverse: Chair · Referee · Macro · Fundamentals · Risk

Sponsor challenges Fetch.ai (ASI:One Agent Challenge): five uAgents (Chair, Referee, Macro, Fundamentals, Risk) registered on Agentverse with mailboxes, talking over the Chat Protocol plus a custom committee protocol. ASI:One Interactive Cards (client picker, receipt, price tags) and the Agent Payment Protocol with Stripe: the Referee is a reusable service any agent can call and pay $0.50 per check.

Cognition — Best Use of Devin: Devin was my second engineer. It authored 19 merged pull requests: the React web app and FastAPI API, the three analyst agents, ASI:One Interactive Cards, the Stripe pay-per-check flow, plain-English rule extraction, the hard synthetic clients, the deployment (Docker, Render, Vercel), and the full implementation of the Paper design. I wrote specs, reviewed every PR, ran the tests and merge-tested them before merging. That's how one person shipped a five-agent system in 24 hours.

Paper — Best Designed Hack: the web app was designed in Paper around one idea, a referee's audit: research-report typography (Newsreader + IBM Plex), ledger tables with tabular numbers, a printable receipt with a torn edge and a rotated ink stamp (PASS / REPAIRED / NEEDS APPROVAL), and a round-by-round tally of broken rules. Color always means something (green = pass, brick = broken, ochre = repaired) and always comes with a text label. The impossible-client screen makes a conflict visible as a bar overflowing its cap, so it reads as calm and helpful, not as an error. Exported frames and tokens live in design/ in the repo; Devin implemented them pixel for pixel.

MLH — Best Use of Gemini API: Gemini 3.5 flash-lite ran my feedback experiment (208 calls, 10 clients × 2 trials), testing whether an AI fixes its own rule violations under three kinds of feedback.

MLH — Best Domain Name from GoDaddy Registry: live at swarmfolio.biz, plus nicetrychatgpt.biz (because the Referee catches the AI's mistakes) and aisaidtrustmebro.biz.

Built With

Share this project:

Updates

Submission history