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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgesight_adapters_langgraph-0.1.1.tar.gz.
File metadata
- Download URL: forgesight_adapters_langgraph-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43d835b1293dc752b7a2cdc32da833279eb1d88f91e6a5e578a5ef06382a2caf
|
|
| MD5 |
75ec3c6f57fc28df91fba02f11dd243a
|
|
| BLAKE2b-256 |
06a24aacb06a3f45a8f3c3c96b1de25d948830b68b50432b7939f00a1ca281df
|
File details
Details for the file forgesight_adapters_langgraph-0.1.1-py3-none-any.whl.
File metadata
- Download URL: forgesight_adapters_langgraph-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24c90484cb119e05aee5db9de0873966d71228e982e8d0b144c1ece68785b5fc
|
|
| MD5 |
246b64602f50b6f72d479050236d0913
|
|
| BLAKE2b-256 |
bc1e86395c9baf5f5341da7a5babc9489e8bff5c9f89243b95bb51e128a9cc9e
|