tsan-report-analyzer

tsan-report-analyzer is an agent for coding agents from ReviewToolkits/cpython-review-toolkit. It costs 289 tokens per session (2,233 once invoked), scanned A, original, MIT.

An agent that examines ThreadSanitizer reports from a free-threaded CPython build, a Python build designed to run without the usual global interpreter lock. ThreadSanitizer is a tool that detects unsynchronized access to shared memory by multiple threads.

In plain words
What is it for?
Use it to triage race reports from a CPython build made with --disable-gil, identify races in the runtime, assess their severity, and suggest next steps.
Why use it?
Raw ThreadSanitizer output can contain many repeated or unrelated reports. This agent groups duplicate races, filters out test and third-party noise, and focuses on races in CPython itself.

Agent

Part of the cpython-review-toolkit plugin — 7 commands, 23 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/reviewtoolkits/cpython-review-toolkit/tsan-report-analyzer
Clone the repo
git clone --depth 1 https://github.com/ReviewToolkits/cpython-review-toolkit

Or install cpython-review-toolkit, the plugin that ships this one along with the rest of its 7 commands, 23 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tsan-report-analyzer

README.md
[![agentmods](https://agentmods.dev/badge/agents/reviewtoolkits/cpython-review-toolkit/tsan-report-analyzer.svg)](https://agentmods.dev/agents/reviewtoolkits/cpython-review-toolkit/tsan-report-analyzer)
Your own site
<a href="https://agentmods.dev/agents/reviewtoolkits/cpython-review-toolkit/tsan-report-analyzer"><img src="https://agentmods.dev/badge/agents/reviewtoolkits/cpython-review-toolkit/tsan-report-analyzer.svg" alt="Measured on agentmods" height="20"></a>
Per session 289 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,233 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00289 $0.02233
Opus 5 $0.00144 $0.01117
Sonnet 5 $0.00058 $0.00447
Haiku 4.5 $0.00029 $0.00223

Measured 5d ago against content hash 4748a02f891f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tsan-report-analyzer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/cpython-review-toolkit/agents/tsan-report-analyzer.md · 116 lines

How it starts

The opening of the file, as written. The whole thing — 116 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an expert in triaging ThreadSanitizer (TSan) data-race reports for CPython itself, built free-threaded (--disable-gil / Py_GIL_DISABLED) under -fsanitize=thread. TSan output is notoriously verbose — a single test run can emit thousands of lines of stack traces. Your goal is to turn raw output into actionable findings against CPython's own runtime.

Key concept — and the KEY inversion

TSan detects data races at runtime by instrumenting memory accesses. A data race is:

  • Two threads access the same memory location,
  • at least one access is a write,
  • with no synchronization (happens-before edge) between them.

The inversion vs. the extension-facing toolkits. ft-review-toolkit reviews extensions, so its TSan analyzer treats any race whose frames live in CPython internals as "not the extension's problem" and filters it out. Here CPython is the target, so that logic inverts. A race whose frames are in CPython's own runtime source — Objects/, Python/, Modules/ (non-test), Include/, Parser/, pycore_*is the finding, and you report it. The only noise to filter is:

  • Thread scaffolding: the thread bootstrap (t_bootstrap, do_start_new_thread, thread_run), pthread_*, start_thread, clone.
  • Test-harness modules: the _testcapi / _testinternalcapi / _testbuffer / _xxtestfuzz / _ctypes_test family, and Lib/test/.
  • Third-party / system libraries: libc, libssl, and the sanitizer runtime itself.

A race that touches CPython source on either side is a target race, even if the other side is scaffolding.

Analysis phases

Phase 1: Parse and triage

python <plugin_root>/scripts/parse_tsan_report.py <report_file>

The parser:

  • Splits the report into individual race warnings (separator-bracketed blocks),
  • parses access types (read/write), stack frames, memory location, and thread-creation info,
  • deduplicates races that share the same unordered file:func site pair (the signature field),
  • separates CPython-source races (is_cpython_race) from noise (is_noise),
  • classifies severity (CRITICAL for a global/static-variable race, HIGH for write/write and read/write).

Read the full file on GitHub · 116 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 116 lines · 0 tokens per session scan A 4748a02f891f

Subscribe to this mod's changes

tsan-report-analyzer is an agent published in the GitHub repository ReviewToolkits/cpython-review-toolkit (10 stars, last pushed 1mo ago), licensed MIT. It adds 289 tokens to every session and 2,233 once invoked, about $0.0014 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.