Skip to main content

ForgeSight LangGraph adapter — auto-instrument LangGraph/LangChain agents via callbacks.

Project description

forgesight-adapters-langgraph

The LangGraph / LangChain adapter for ForgeSight. An unchanged LangGraph graph emits a correct ForgeSight span tree — with cost and metrics — by subscribing to LangChain's callbacks.

pip install forgesight-adapters-langgraph
import forgesight
from forgesight_adapters_langgraph import LangGraphAdapter

forgesight.configure()
LangGraphAdapter().instrument()          # subscribe to LangChain/LangGraph callbacks

# Unchanged graph — now fully instrumented:
result = await my_compiled_graph.ainvoke({"task": "review PR #42"})

What it maps

LangChain callback ForgeSight
root chain (graph invoke) agent_run
nested chain (graph node) step
on_chat_model_start / on_llm_* llm_call (+ token usage from the LLMResult)
on_tool_* tool_call (execute_tool)
*_error span ERROR + error.type

Because every adapter targets the same domain model, a LangGraph agent and (say) a CrewAI agent produce comparable agent_runs_total / cost views. Cost is derived by the runtime from the extracted token usage — the adapter never computes cost.

No double-instrument. When a tool call is already covered by an inner span (an MCP tools/call, feat-016), the adapter defers and does not open a second execute_tool.

Explicit handler

Auto-subscription uses LangChain's inheritable-callback hook. You can also pass the handler per-invocation: graph.ainvoke(..., config={"callbacks": [LangGraphAdapter().handler]}).

License

Apache-2.0

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

forgesight_adapters_langgraph-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

forgesight_adapters_langgraph-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for forgesight_adapters_langgraph-0.1.1.tar.gz
Algorithm Hash digest
SHA256 43d835b1293dc752b7a2cdc32da833279eb1d88f91e6a5e578a5ef06382a2caf
MD5 75ec3c6f57fc28df91fba02f11dd243a
BLAKE2b-256 06a24aacb06a3f45a8f3c3c96b1de25d948830b68b50432b7939f00a1ca281df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for forgesight_adapters_langgraph-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24c90484cb119e05aee5db9de0873966d71228e982e8d0b144c1ece68785b5fc
MD5 246b64602f50b6f72d479050236d0913
BLAKE2b-256 bc1e86395c9baf5f5341da7a5babc9489e8bff5c9f89243b95bb51e128a9cc9e

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