Loosely-Typed JSON Is Killing Your AI Agents. Try This Instead.

You’ve probably been there. It’s late, and your multi-agent system is spiraling. Agent A writes a task status to a JSON file. Agent B overwrites it with a slightly different format. Agent C reads the malformed data, hallucinates a catastrophic next step, and burns through your API budget.

You think your AI is hallucinating, but it’s actually just reading a corrupted ledger of its own mistakes.

Most developers treat agentic state like a simple, unstructured key-value store. It’s the path of least resistance. You dump some JSON into a file or a database, let the agents read and write to it, and hope the LLMs figure it out. If things break, you just add more retries. But this is a ticking time bomb. The real bottleneck in autonomous workflows isn’t AI capability—it’s state governance.

Flexibility in state management isn’t a feature; it’s a liability masquerading as convenience.

When multiple agents write conflicting or malformed data to a loosely-typed blob, the cascading failures are silent and incredibly hard to debug. You aren’t fighting the AI; you’re fighting the lack of infrastructure around it. We need to stop giving agents a blank check to corrupt their own shared memory.

Enter schema-enforced, Git-based state management. A developer recently demonstrated a brilliant approach to this exact problem. By combining Claude agents with a Git-backed GraphQL API (using the Commitspark library), they created an environment where agents can’t just dump unstructured garbage. The agents fetch the schema and author their own GraphQL calls, with the system automatically enforcing that all written data is schema-conformant.

But the real magic is the audit trail. Because the state is entirely Git-backed, every change is a commit. A third, independent agent acts as a reviewer, looking at the actual diffs. If an agent makes a bad change, the reviewer simply reverts the commit. The frustration of debugging unpredictable agent behavior is instantly replaced by the reassuring clarity of a full audit trail and automated rollback.

Autonomy without accountability is just chaos with a UI.

If you are building multi-agent systems, shared state corruption is the silent killer of reliability. Moving away from loosely-typed JSON to a rigid, diff-able, schema-enforced system isn’t just a nice-to-have technical detail. It’s the foundation of trust in autonomous workflows. Stop blaming the model for your bad state management. Enforce the schema, track the diffs, and let your agents actually do their jobs.

FAQ

Q: Isn't loosely-typed JSON with retries good enough for simple agents?

A: It's a trap. JSON works until you scale to multiple agents writing concurrently. The moment a format mismatch happens, retries just amplify the error and burn your token budget.

Q: What's the practical implication of using Git-backed state?

A: You get an automatic, diff-able audit trail of every state change. If an agent makes a bad move, you can literally revert the commit, meaning you can safely let autonomous agents modify state without fear of permanent corruption.

Q: Isn't forcing agents to write GraphQL too rigid and slow?

A: No, it's called safety. Agents fetching a schema and writing conformant data prevents the cascading failures caused by unstructured garbage. The slight overhead is a small price to pay for guaranteed data integrity.

📎 Source: View Source