trulens.core.utils.trace_provider¶
trulens.core.utils.trace_provider
¶
Provider interface for trace-specific parsing and plan extraction.
This allows different app integrations (LangGraph, LangChain, etc.) to provide their own trace parsing logic while keeping the core compression generic.
Classes¶
TraceProvider
¶
Bases: ABC
Abstract base class for trace provider-specific parsing.
Functions¶
can_handle
abstractmethod
¶
extract_plan
abstractmethod
¶
extract_execution_flow
abstractmethod
¶
extract_agent_interactions
abstractmethod
¶
compress_trace
¶
compress_with_plan_priority
¶
compress_with_plan_priority(
trace_data: Dict[str, Any],
target_token_limit: int = DEFAULT_TOKEN_LIMIT,
) -> Dict[str, Any]
Compress trace with plan preservation as highest priority. If context window is exceeded, compress other data more aggressively.
| PARAMETER | DESCRIPTION |
|---|---|
trace_data
|
Raw trace data to compress |
target_token_limit
|
Target token limit for context window management
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Compressed trace data with plan preservation prioritized |
GenericTraceProvider
¶
Bases: TraceProvider
Generic trace provider for standard trace formats.
Functions¶
can_handle
¶
Generic provider handles any trace data as fallback.
extract_plan
¶
Extract plan using generic field names.
extract_execution_flow
¶
Extract execution flow using generic span structure.
extract_agent_interactions
¶
Extract agent interactions using generic message structure.
compress_trace
¶
compress_with_plan_priority
¶
compress_with_plan_priority(
trace_data: Dict[str, Any],
target_token_limit: int = DEFAULT_TOKEN_LIMIT,
) -> Dict[str, Any]
Compress trace with plan preservation as highest priority. If context window is exceeded, compress other data more aggressively.
| PARAMETER | DESCRIPTION |
|---|---|
trace_data
|
Raw trace data to compress |
target_token_limit
|
Target token limit for context window management
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Compressed trace data with plan preservation prioritized |
TraceProviderRegistry
¶
Registry for trace providers with priority ordering.
Functions¶
register_provider
¶
register_provider(provider: TraceProvider)
Register a trace provider. Last registered has highest priority.
get_provider
¶
get_provider(trace_data: Dict[str, Any]) -> TraceProvider
Get the first provider that can handle the trace data.
Functions¶
register_trace_provider
¶
register_trace_provider(provider: TraceProvider)
Register a trace provider globally.
get_trace_provider
¶
get_trace_provider(
trace_data: Dict[str, Any]
) -> TraceProvider
Get appropriate trace provider for the given data.