LangChain and LangGraph
Version 0.5 adds live capture through the langchain-core callback protocol. LangChain and LangGraph both dispatch that protocol, so the same handler records chains, graph nodes, chat models, tools, retrievers, agent actions, and errors into a v3 opentine repository while they run.
Install the optional callback dependency
python -m pip install "opentine[langchain]==0.5.0"The extra installs langchain-core; it does not install a complete LangChain or LangGraph application stack. Keep the framework packages your application already uses. Importing opentine itself never imports LangChain.
Record an invocation
1from opentine import Repo
2from opentine.integrations.langchain import OpenTineCallbackHandler
3
4repo = Repo.init("runs")
5handler = OpenTineCallbackHandler(repo, ref="heads/main")
6
7graph.invoke(
8 {"question": "What changed in this branch?"},
9 config={"callbacks": [handler]},
10)
11
12run_id = handler.run_id
The run opens on the first callback and finalizes after the final open span closes. One normal invoke() becomes one v3 repository run;handler.run_id is the run in flight or the most recently finalized run.
Callback mapping
- Callback
run_idandparent_run_idbecome span identity and parent edges. - Chains, graph nodes, LLMs, and chat models are recorded as model events.
- Tools and retrievers are recorded as tool events.
- Error callbacks close or create explicit error events rather than dropping partial work.
- Reported token usage is normalized into opentine usage dimensions.
- Framework metadata and tags remain attributes on the recorded events.
Incomplete callbacks and failure policy
# Finalize deliberately if the framework leaves callbacks open.
run_id = handler.flush()
# A reusable handler retains the IDs of completed invocations.
completed_run_ids = handler.run_idsCall flush() when an interrupted framework execution leaves callbacks open; the remaining spans are recorded as incomplete. By default, a provenance capture failure does not terminate the agent run. Pass raise_error=Trueto the handler when a refusing repository must fail the host invocation instead.
Live capture versus log import
Live capture receives events as the framework dispatches them. Serialized LangChain, LlamaIndex, AutoGen, CrewAI, and OpenAI Agents logs can instead be imported after execution through tine import. CrewAI remains post-hoc only in v0.5; there is no live CrewAI callback adapter.