langgraph-sfm
Causal intent monitoring for LangGraph agents using a bundled Structural Final Models core.
langgraph-sfm adds an SFM intent-analysis node and run monitor to LangGraph-style agent workflows. This package now bundles the full relocated SFM core under a single sfm/ package, so the default node uses the real core backend instead of a lightweight fallback.
Install
pip install langgraph-sfm
# optional, only when running inside LangGraph itself
pip install "langgraph-sfm[langgraph]"
Quickstart
from sfm_langgraph import SFMIntentAnalyzerNode, SFMAgentMonitor
analyzer = SFMIntentAnalyzerNode()
monitor = SFMAgentMonitor()
state = {
"run_id": "agent-run-1",
"last_action": "call_search_tool",
"candidate_goals": [{"goal_variable": "answer_user_question"}],
"graph": {
"nodes": ["agent_action", "answer_user_question"],
"edges": [["agent_action", "answer_user_question"]],
},
"stated_goal": "answer_user_question",
}
state.update(analyzer(state))
state.update(monitor(state))
print(state["sfm_analysis"])
print(state["sfm_monitor"])
What is inside
sfm_langgraph/ # LangGraph-compatible node, monitor and CLI
sfm/ # bundled full SFM core and its required support modules
tests/ # public smoke/contract tests
examples/ # quickstart examples
The bundled core keeps the public repository clean: instead of publishing many top-level internal packages (amantia, runtime, scm_parts, etc.), they live inside sfm/. A small compatibility bootstrap preserves the core's internal imports.
LangGraph usage
from typing import Any, TypedDict
from langgraph.graph import END, START, StateGraph
from sfm_langgraph import SFMIntentAnalyzerNode, SFMAgentMonitor
class AgentState(TypedDict, total=False):
run_id: str
last_action: str
candidate_goals: list[dict[str, Any]]
graph: dict[str, Any]
stated_goal: str
sfm_analysis: dict[str, Any]
sfm_monitor: dict[str, Any]
requires_human_review: bool
sfm_gate_status: str
builder = StateGraph(AgentState)
builder.add_node("sfm_intent", SFMIntentAnalyzerNode())
builder.add_node("sfm_monitor", SFMAgentMonitor())
builder.add_edge(START, "sfm_intent")
builder.add_edge("sfm_intent", "sfm_monitor")
builder.add_edge("sfm_monitor", END)
graph = builder.compile()
Epistemic boundary
This project is a research/observability layer. It does not prove an agent's “true goal”. It reports plausible intent hypotheses, side effects, deception-risk signals and the level at which a claim is authorized or withheld.
Recommended wording:
Detect plausible agent intentions, side effects, and deception risk with explicit epistemic claim levels.
Development
python -m pip install -e ".[test]"
python -m pytest
python -m sfm_langgraph.cli
python -m build
License
MIT.
Metadata
Release files for langgraph-sfm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langgraph_sfm-0.1.1.tar.gz | 558.1 kB | Without provenance | Details for langgraph_sfm-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langgraph_sfm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for langgraph_sfm-0.1.1-py3-none-any.whl |
Total release size: 1.2 MB
Release files / langgraph_sfm-0.1.1.tar.gz
| Download URL | langgraph_sfm-0.1.1.tar.gz |
|---|---|
| Size | 558.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11e87044f53db594c96f76727e58cdc6b5b421ed618126ffb0253b863579f5e5
|
|
BLAKE2b-256 checksum How to use checksums |
22dd8973eb3da61d42cb61e3a415267c01243be98bba54149c9fcaf5c0de98f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / langgraph_sfm-0.1.1-py3-none-any.whl
| Download URL | langgraph_sfm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 666.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
466cdebcf121a1cbe13a8292de5da8c43cb3636032bdd7805c10e1b21e7bf905
|
|
BLAKE2b-256 checksum How to use checksums |
ff8bbe006e9b8709dee2a6b3f700adb24501dc81b79dcdad05f40ee56c0a7caf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for langgraph-sfm 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.