Skip to content

trulens.apps.langgraph.trace_provider

trulens.apps.langgraph.trace_provider

LangGraph-specific trace provider for plan extraction and parsing.

This module contains all LangGraph-specific logic for parsing traces, extracting plans from Command structures, and understanding LangGraph state.

Classes

LangGraphTraceProvider

Bases: TraceProvider

LangGraph-specific trace provider that understands Command structures and graph state.

Functions
can_handle
can_handle(trace_data: Dict[str, Any]) -> bool

Check if this is a LangGraph trace by looking for LangGraph-specific indicators. Checks ALL spans for indicators, not just the first few.

extract_plan
extract_plan(trace_data: Dict[str, Any]) -> Optional[Any]

Extract plan from LangGraph trace, handling Command structures and graph state.

extract_execution_flow
extract_execution_flow(
    trace_data: Dict[str, Any]
) -> List[Dict[str, Any]]

Extract detailed execution flow with reasoning chain from LangGraph trace.

extract_agent_interactions
extract_agent_interactions(
    trace_data: Dict[str, Any]
) -> List[Dict[str, Any]]

Extract detailed agent interactions with reasoning and data flow.

compress_trace
compress_trace(
    trace_data: Dict[str, Any]
) -> Dict[str, Any]

Compress trace with enhanced detail preservation for logical consistency.

compress_with_plan_priority
compress_with_plan_priority(
    trace_data: Dict[str, Any],
    target_token_limit: int = 100000,
) -> Dict[str, Any]

Compress trace with plan priority and enhanced reasoning preservation.

Functions

register_langgraph_provider

register_langgraph_provider()

Register the LangGraph trace provider.