Skip to main content

langchain-fathom

A coherence read for LangChain agents, as an agent middleware.

A long-running agent loses coherence with its own decisions. It renames a field at one step, then writes the old name at a later one. It marks a record done that it never wrote. The run reports success, and the contradiction ships. langchain-fathom watches the agent run and, when it finishes, names the step where a later action contradicts an earlier commitment.

The middleware observes the agent and does not change what it does. It maps the tool calls in the message history to a committed-state op stream, sends that stream to the Fathom read, and reports the findings. The read is deterministic and needs no model access.

Install

pip install langchain-fathom

Use

from langchain.agents import create_agent
from langchain_fathom import FathomMiddleware

agent = create_agent(
    model="gpt-5.5",
    tools=[...],
    middleware=[FathomMiddleware()],
)

result = agent.invoke({"messages": [...]})

By default the middleware logs any findings through the fathom logger. Two other modes fit a test suite or a pipeline.

FathomMiddleware(on_finding="raise")   # raise FathomCoherenceError when a run is not coherent
FathomMiddleware(on_finding="store")   # put the verdict on agent state under the "fathom" key

Under store, the verdict arrives on the result.

result = agent.invoke({"messages": [...]})
verdict = result["fathom"]
verdict["coherent"], verdict["findings"]

The middleware declares that key in its own state schema, so a graph that carries a state schema of its own keeps the verdict rather than dropping it. Version 0.1.0 declared nothing, and an orchestrator such as a deepagents agent dropped the verdict before the caller saw it.

If the run is a rename or a migration, tell the read which token replaced which, so it also reports records left on the old value at the end.

FathomMiddleware(supersede=[("guest_id", "customer_id")])

What it finds

Finding The agent...
stale_reference acts on a record it already removed or renamed away
superseded_value writes a value it already replaced
residual ends the run with a record still carrying a value it replaced elsewhere
duplicate_commit adds an entity a collection already holds
post_commit_mutation changes a record after committing it

A coherent run returns coherent and the middleware reports nothing else.

Agents that delegate

The middleware reads the calls of the agent it rides. An orchestrator that hands work to sub-agents runs each sub-agent as its own agent with its own message history, so an orchestrator-level middleware sees the delegation and the orchestrator's own tools, and not what the sub-agents did. Give each sub-agent its own FathomMiddleware to cover the whole run. On one deepagents research run we measured, the orchestrator's middleware alone returned 3 of the 9 findings a trace across every sub-agent returned.

Your own tool names

The read knows common state-writing tool names. For tools with your own names, map them once and pass the file.

FathomMiddleware(mapping_path="tools.json")
{"save_decision": {"op": "set", "kind": "decision", "key": "topic", "value": "text"},
 "confirm_booking": {"op": "commit", "kind": "flight", "key": "booking"}}

The read and the repair

The middleware is the read. It tells you where coherence broke. Embedded Risk Analytics also runs a hosted service that acts on what the read finds and re-grounds the agent before the contradiction ships. Both run free with a key from fathom key in the fathom-read package, or write to contact@embeddedriskanalytics.com to run the read on a workflow of your own.

MIT licensed.

Metadata

Release files for langchain-fathom 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-fathom 0.1.1
File Size Uploaded
langchain_fathom-0.1.1.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-fathom 0.1.1
File Interpreter ABI Platform
langchain_fathom-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / langchain_fathom-0.1.1.tar.gz

Download URL langchain_fathom-0.1.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5f259f86ffbfe24e1c275a385b72db86c4c4d262c4015c87594a8910f2848719
BLAKE2b-256 checksum
How to use checksums
52849542f573a746c5a1b02f8444855d0b97ec739d891694d2dfbe67c88019a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / langchain_fathom-0.1.1-py3-none-any.whl

Download URL langchain_fathom-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd0ec54abd8e842eedb6f8928da077cdee0ff189b2be17804479d84e17e47f59
BLAKE2b-256 checksum
How to use checksums
59ad41ccfe5d90b383f4672a1fbea7f3f96a74dee5cbcb05ef538eacb0b965aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page