GitHub Complex Case Studies

Case Study: How a Multi-Agent System Debates a Stock Trade

Analyst teamDebate layerResearch managerTrader + riskteamPortfoliomanager

Most of this series has covered concepts in the abstract. This article and the next look at two real, open-source systems that put those concepts to work, starting with TradingAgents — a genuine, shipped multi-agent trading system, not a teaching toy — where nearly every idea covered so far shows up inside one working codebase.

The five-stage pipeline

TradingAgents runs a sequential pipeline with a deliberative debate stage in the middle. An analyst team of four specialists — Fundamentals, Sentiment, News, and Technical — each generates a domain report using its own tools, drawing from real data sources including Yahoo Finance, Alpha Vantage, StockTwits, Reddit, and prediction markets, each sitting behind its own tool. Those four reports converge on a debate layer, where a Bullish researcher and a Bearish researcher argue the same position from deliberately opposite goals before anyone downstream sees a proposal. A research manager then synthesizes the two opposing arguments into one coherent thesis, which passes to a trader and risk team: the trader proposes timing and size, while three risk personas — Risky, Neutral, and Safe — along with a risk judge, gatekeep that proposal against hard constraints. Finally, a portfolio manager renders the actual decision, parsed into a structured, five-tier rating running from Buy through Overweight, Hold, Underweight, to Sell.

The uniform contract that makes it work

One design detail is easy to miss but does a great deal of work: every analyst follows the exact same business contract — a stated goal, fed by one category of data, producing a key-points summary the rest of the pipeline can consume. That uniformity is what lets four independently specialized analysts feed cleanly into the same downstream debate stage without custom integration logic for each one. A shared contract between independently-built components is very often what makes a multi-agent pipeline composable rather than brittle.

Debate as a genuine architectural choice

The debate between the Bullish and Bearish researchers runs in both directions at once — each side actively rebuts the other, rather than simply stating an initial position and moving on. This is a direct, real-world instance of the evaluator-optimizer workflow pattern: the whole point of structured debate is to surface the counter-case explicitly before any single view is trusted, rather than letting one perspective dominate simply because it spoke first or spoke more confidently.

Independent risk gatekeeping as isolation applied to governance

The three risk personas that stress-test the trader's proposal are a governance mechanism, separate from the trade thesis itself — and this separation is worth connecting back to context isolation: the risk team's job is specifically not to be persuaded by the same narrative that produced the trade idea, so keeping it structurally independent is what keeps it a genuine check rather than a rubber stamp.

Design decisions worth naming explicitly

Four choices in this system are each traceable to a concept from earlier in this series. Debate before synthesis is evaluator-optimizer in disguise. Independent risk gatekeeping is context isolation applied to governance rather than code review. A structured, five-tier decision rather than free text is the schema-enforcement discipline applied to a financial decision. And memory plus checkpointing — recalling past decisions per ticker, and resuming interrupted runs from a saved state — is the same persistent-memory and harness-checkpointing mechanics covered earlier, doing real work in a domain where a crashed run losing its place would be a genuine problem.

The system is also deliberately provider-agnostic — it can run against OpenAI, Google, Anthropic, or several self-hosted open-weight models — and makes a careful, explicit distinction between deterministic and non-deterministic elements: sampling and live data feeds are non-deterministic by nature, while ticker resolution and price grounding are deliberately pinned deterministic against verified snapshots, so the parts of the system where being wrong is expensive are never left to model variance.

Questions to bring to your team

  • Where else could a "debate before deciding" pattern reduce single-model bias in your own decisions?
  • What would a risk-gatekeeping layer look like in your domain?

Also available in Čeština

← Data Sovereignty in the Age of Agents: What "Zero Data Retention" Really Means Case Study: Automating a Job Search With an Agentic Workflow →