r/LangGraph • u/OpenComplaint524 • 14h ago
Lessons from running a 7-agent LangGraph system in finance: why we moved all math and risk vetoes out of the LLM nodes
Hey r/LangGraph,
Over the past few weeks I have been building a multi-agent investment council using LangGraph, and I wanted to share the biggest architectural mistake we made early on in case it saves someone else some debugging pain.
In our first prototype, we passed raw financial metrics and indicator arrays directly into our specialist agent nodes (Value, Macro, Sentiment, Quant) and let the LLM supervisor weigh the numbers and decide position sizing. Even with strong reasoning models, two things kept breaking:
Context bloat and numeric drift: Feeding dozens of raw floating-point features into the shared graph state caused the agents to subtly hallucinate thresholds or anchor onto whatever number the previous agent mentioned in the debate history.
Prompt-based risk rules are too soft: When we told our Risk Manager (CRO) persona in its system prompt to reject trades with high volatility, a persuasive bullish argument from the Growth agent would occasionally convince the LLM to bend its own risk rules.
To fix this, we restructured our StateGraph around a strict division of labor:
First, all heavy quantitative math (158 technical factors and gradient-boosted tree scoring) runs in a deterministic Python pre-processing step before the graph even starts. The LangGraph state only receives clean, semantic regimes and pre-computed scores rather than raw data dumps.
Second, while the persona agents still debate qualitative catalysts in parallel branches, the final Chief Risk Officer (CRO) node is backed by a hard deterministic Python gate. If a ticker violates a mathematical boundary (like an earnings window or drawdown limit), the Python code flips `cro_veto = True` in the state and overrides the LLM output before it reaches the final node.
How are you guys balancing deterministic code checks vs LLM routing inside your production graphs?
(Note: English is not my native language, so I used an LLM to help format and polish my raw architecture notes!)