Skip to main content

Causal intent monitoring for LangGraph agents using bundled Structural Final Models.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langgraph_sfm-0.1.1.tar.gz (558.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langgraph_sfm-0.1.1-py3-none-any.whl (666.5 kB view details)

Uploaded Python 3

File details

Details for the file langgraph_sfm-0.1.1.tar.gz.

File metadata

  • Download URL: langgraph_sfm-0.1.1.tar.gz
  • Upload date:
  • Size: 558.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for langgraph_sfm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 11e87044f53db594c96f76727e58cdc6b5b421ed618126ffb0253b863579f5e5
MD5 fcb851f81b37d6d4107164ed962e14ec
BLAKE2b-256 22dd8973eb3da61d42cb61e3a415267c01243be98bba54149c9fcaf5c0de98f4

See more details on using hashes here.

File details

Details for the file langgraph_sfm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langgraph_sfm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 666.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for langgraph_sfm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 466cdebcf121a1cbe13a8292de5da8c43cb3636032bdd7805c10e1b21e7bf905
MD5 63df1194313ecf228d7dbedba80606b8
BLAKE2b-256 ff8bbe006e9b8709dee2a6b3f700adb24501dc81b79dcdad05f40ee56c0a7caf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page