I built a LangChain middleware that audits whether an agent remains coherent with the state it has already committed.
Over a long run, an agent can rename a field at one step and then, several steps later, reference the superseded name. Each step returns success, the run terminates cleanly, and the contradiction propagates downstream. Nothing in the trace surfaces it, because no individual step failed.
langchain-fathom inspects the message history after a run, folds the successful tool calls into a ledger of what the agent actually committed, and identifies the step at which a later action contradicts an earlier commitment. It observes and reports; it never alters the agent’s behavior.
pip install langchain-fathom
from langchain.agents import create_agent
from langchain_fathom import FathomMiddleware
agent = create_agent(model=..., tools=[...], middleware=[FathomMiddleware()])
If you are not using create_agent, it also reads raw LangGraph checkpoints directly. The analysis is deterministic and requires no model access.
The repo is GitHub - RightRudderAI/langchain-right-rudder: LangChain agent middleware that flags the step where an agent contradicts its own earlier action. Deterministic, no model calls, fits tests and CI. · GitHub, with the underlying read and its other adapters at GitHub - RightRudderAI/right-rudder: Catch the step where an AI agent contradicts its own earlier decision. CLI and adapters for LangGraph, CrewAI, Letta, OpenInference, DBOS and multi-agent logs, plus an expiry read for long-running agents. · GitHub. The middleware is the diagnostic layer, and it is free. We also operate a hosted service that acts on its findings and re-grounds the agent before the contradiction ships, which is the commercial component. I would like to know where it misreads your agents.