Ctxblame – "Git blame" for LLM agent decisions via counterfactual replay
Open-source tool ctxblame v0.2.2 isolates LLM agent prompt causes via counterfactual replays, raising attribution accuracy by ten points on benchmark suites.
By Dillip Chowdary • Nov 29, 2026 • Source: github.com

At a glance
- Product
- ctxblame
- Software version
- v0.2.2
- Pricing
- Free open-source tool; default $5 replay budget cap
- Availability
- Available via pip and uvx
- Supported protocols
- Anthropic Messages and OpenAI Chat Completions
- Model coverage
- Validated on Qwen3-14B, Llama-3.1-8B, and open models
In this post
Developers released ctxblame version 0.2.2, an open-source tool designed to isolate which context chunks trigger decisions in language model agents. According to github.com's report, the utility executes counterfactual replays with specific prompt tokens removed, deriving causal evidence without trusting model explanations. It operates across architectures by evaluating traces against Anthropic Messages and OpenAI Chat Completions.
This report analyzes how ctxblame captures agent traffic, ablates prompt components, preserves prompt cache hits, and statistically certifies causal attributions. The breakdown is designed for artificial intelligence engineers, agent developers, and researchers seeking deterministic debugging tools for complex workflows. Readers will examine the underlying proxy architecture, search heuristics, and validation algorithms.
01Local recording proxies and execution wrappers
The tool intercepts agent traffic through two local proxy servers listening on dynamic ports for Anthropic Messages and OpenAI Chat Completions formats. When invoked through the wrapper command, the system assigns environment variables redirecting traffic through proxies while preserving existing upstreams like DeepSeek or local vLLM instances. The proxies terminate automatically once the wrapped agent process exits, mirroring its return code.
Note: Network interception requires agent clients to respect standard environment base URL variables during runtime execution. Requests targeting non-supported endpoints, such as the OpenAI Responses API, are forwarded directly to upstream hosts without being indexed into the local trace archive.
02Replay stability and targeted context ablations
Counterfactual evaluation begins by replaying a targeted step across multiple runs without executing underlying tools to establish baseline decision probability. The replay engine tracks cumulative token costs against a five-dollar default budget ceiling recorded in a local ledger. If model output cannot be reproduced consistently across unchanged baseline runs, the analysis flags the behavior as unstable and halts.
Ablation passes systematically remove prompt elements, including tool descriptions, reasoning traces, conversational turns, or specific text strings matching regular expressions. When a tool call is removed, ctxblame strips its corresponding response, purges resulting empty messages, and merges adjacent same-role messages to preserve schema validity. Engineers configure decision equivalence across varying tolerance levels targeting tool names, arguments, or broader semantic intent.
| Matching Mode | Target Evaluation | Equivalence Criterion |
|---|---|---|
| intent | Semantic operation goal | Equates actions like Read and Bash cat |
| exact | Full invocation signature | Requires identical tool names and parameters |
| key-arg | Specific argument substring | Validates command arguments using regex |
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
03Suffix-first stratified search and cache preservation
The search algorithm partitions context into stratified tiers ordered from prefix to suffix, spanning tool definitions, system instructions, earlier history, and recent dialogue turns. The latest user instruction containing task text remains permanently protected against removal throughout the ablation cycle. Context markers injected by agent harnesses, including system reminders and environment details, are treated as standard removable units during search passes.
Rather than modifying prompt prefixes immediately, search expands backwards from tail history toward early prefixes to maximize prompt KV-cache utilization. On Anthropic connections, cache control breakpoints shift to the unmutated prefix of each payload. When removing a chunk collapses an action category entirely, the system isolates that segment as a workflow precondition, protecting it during subsequent choice evaluations.
04Hitchhiker pruning and family-wise error auditing
When the attribution algorithm identifies multi-member context bundles, it performs leave-one-in restoration checks to eliminate spurious correlations and noisy hitchhikers. Holding other candidate chunks omitted while restoring a single chunk confirms whether that specific segment independently regenerates the target decision. Surviving context blocks undergo line-by-line refinement, distinguishing strict conjunction requirements from redundant disjunctive rule carriers that standard leave-one-out passes overlook.
Candidate attributions are tested against random prompt removals of identical lengths to ensure observed decision changes reflect causal mechanisms rather than generic sensitivity. If arbitrary deletions reproduce identical behavioral flips, ctxblame categorizes the segment as general unspecific context rather than an isolated cause. Final validation dispatches twenty fresh replays under exact one-sided binomial testing with Holm family-wise error corrections at alpha 0.05.
05Forced action replays and steering identification
Version 0.2.2 introduces forced tool execution via tool choice constraints to determine whether a context segment merely prompts action or directly steers command parameters. When analyzing specific tools like Bash, the engine compares ablated prompt runs directly against equally forced baseline replays. Diagnostic output details alternate actions generated during forced replays, showing when an agent substitutes status checks for linter invocations.
Note: Tool forcing requires API endpoints that support explicit tool selection constraints during generation. In environments utilizing extended reasoning parameters or intent-level matching abstractions, tool forcing cannot be enforced, prompting the diagnostic reporter to fall back to unforced baseline evaluations.
Frequently asked questions
What does ctxblame do when debugging language model agents?
It identifies which context chunk caused an agent decision by replaying requests with pieces of context removed. The tool relies on empirical replays rather than self-generated explanations.
How does the software capture agent traffic for analysis?
The tool starts local recording proxies for Anthropic and OpenAI formats and sets base URL environment variables. Every request and response exchange is saved to a local JSON-lines trace file while redacting authentication headers.
What capability was added in version 0.2.2?
Version 0.2.2 adds forced tool replays using tool choice parameters to determine whether a context chunk merely makes an agent act or steers what it does. This addition improved attribution F1 scores by nine to ten points on benchmark suites.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement