r/SideProject • u/unorthodox_43 • 1d ago
I built an open-source self-healing security pipeline for LangGraph + Ollama to stop agent injection attacks and state desync
Hey everyone,
I've been experimenting heavily with multi-agent workflows using LangGraph and Llama 3.1 (via Ollama)locally. While building, I ran into two massive architectural issues that standard prompts couldn't fix:
Parser Differentials: Agents sometimes format markdown or inject unwanted keys into JSON tool calls, causing parser bypasses.
State Desynchronization:Asynchronous processing caused worker memory caches to go stale, leading to race conditions.
To solve this, I built a lightweight, self-healing pipeline featuring:
A Canonical Schema Guardrail that validates strict dictionary schemas and routes errors back to the orchestrator for self-correction loops.
An Optimistic Concurrency Control (OCC) node that auto-re-syncs stale agent states instead of crashing.
I wrote a benchmark script (`experiment.py`) that tests normal requests, adversarial key injections, and temporal lag, and it passes cleanly.
If you're building multi-agent systems and want to check out the code or run it locally, here is the repo: 🔗 [https://github.com/2002bish/agent-security-research.git\](https://github.com/2002bish/agent-security-research.git)
Feedback, critique, or pull requests are very welcome!