Expand description
Context tracing for RLM iterations.
Tracks token budget and context events per RLM iteration to enable analysis of context window usage and optimization opportunities.
§Events Traced
- SystemPrompt: Initial system message with context summary
- GrepResult: Results from grep operations
- LlmQueryResult: Results from sub-LLM calls
- AssistantCode: Code generated by the assistant
- Final: Final answer returned
§Usage
ⓘ
use codetether_agent::rlm::context_trace::{ContextTrace, ContextEvent};
let mut trace = ContextTrace::new(max_tokens);
// Log events as they occur
trace.log_event(ContextEvent::SystemPrompt {
content: system_prompt.clone(),
tokens: count_tokens(&system_prompt),
});
trace.log_event(ContextEvent::GrepResult {
pattern: "async fn".to_string(),
matches: 5,
tokens: 150,
});
// Get summary statistics
let stats = trace.summary();
println!("Total tokens: {}", stats.total_tokens);
println!("Budget used: {:.1}%", stats.budget_used_percent);Structs§
- Context
Trace - Context trace for a single RLM analysis run.
- Context
Trace Summary - Summary statistics for a context trace.
Enums§
- Context
Event - A context event logged during RLM iteration.