Skip to content

Python (LangGraph / CrewAI)

The Python side ships as three PyPI packages: a generic client plus two framework adapters.

Package Install Purpose
lookspan pip install lookspan Generic client / exporter (LookspanClient)
lookspan-langgraph pip install lookspan-langgraph LangGraph / LangChain callback handler
lookspan-crewai pip install lookspan-crewai CrewAI event listener

Attach the callback handler to any LangChain/LangGraph run:

from lookspan import LookspanClient
from lookspan_langgraph import LookspanCallbackHandler
client = LookspanClient(endpoint="http://127.0.0.1:3100/api/ingest")
handler = LookspanCallbackHandler(client=client, agent_id="my-agent")
result = graph.invoke({"messages": []}, config={"callbacks": [handler]})
client.flush()

The handler accepts agent_id and session_id for attribution and session grouping.

For CrewAI, attach an event listener — one call wires it up:

from lookspan import LookspanClient
from lookspan_crewai import attach_lookspan
client = LookspanClient(endpoint="http://127.0.0.1:3100/api/ingest")
attach_lookspan(client, agent_id="crew", session_id="run-1")
# ... run your crew as usual; spans are emitted automatically ...
client.flush()

LookspanClient is a thin convenience wrapper around an HTTP exporter:

from lookspan import LookspanClient
client = LookspanClient(endpoint="http://127.0.0.1:3100/api/ingest")
# build and emit spans directly, then drain the buffer before exit
client.flush()

Its constructor takes endpoint (default http://127.0.0.1:3100/api/ingest), an optional custom exporter, a source label, and capture_content (default False). Content is omitted from exported spans by default; set capture_content=True only when prompts and replies are safe to persist. Always call client.flush() before your process exits so buffered spans are sent.

More runnable examples live in the examples/ directory of the repository.

Lookspan is part of Fervon, the autonomous software studio of Jonathan Martín — local-first developer tools built by fleets of AI agents.