Skip to main content

Module trace_analyzer

Module trace_analyzer 

Source
Available on crate feature eval only.
Expand description

Execution trace analysis for detecting inefficiencies.

The TraceAnalyzer inspects agent event streams to identify redundant tool calls, execution loops, and other patterns that waste tokens or time. It produces a TraceAnalysis summary with an efficiency score and per-pattern diagnostics.

§Example

use adk_eval::trace_analyzer::{TraceAnalyzer, ToolCallRecord};
use serde_json::json;

let analyzer = TraceAnalyzer::new();
let calls = vec![
    ToolCallRecord { name: "read_file".into(), args: json!({"path": "a.txt"}) },
    ToolCallRecord { name: "read_file".into(), args: json!({"path": "a.txt"}) },
    ToolCallRecord { name: "write_file".into(), args: json!({"path": "b.txt"}) },
];
let analysis = analyzer.analyze_tool_calls(&calls);
assert!(analysis.efficiency_score < 1.0);

Structs§

ToolCallRecord
A single tool call record for direct analysis without full Events.
TraceAnalysis
Summary of trace analysis results.
TraceAnalyzer
Analyzes agent execution traces for inefficiencies.
TraceDiagnostic
A detected trace inefficiency.

Enums§

TracePattern
Types of trace inefficiency patterns.