error-path-analyzer

A code-review agent for finding error-handling mistakes in CPython, the C program that runs Python, especially where failures or exceptions are lost or used incorrectly.

In plain words
What is it for?
Use it to scan CPython C source with scanerrorpaths.py and inspect unchecked fallible results, missing exceptions, and accidentally cleared exceptions.
Why use it?
It helps catch bugs that can hide user errors, produce misleading system errors, or return invalid results when memory allocation or another operation fails.

Agent

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/error-path-analyzer
Clone the repo
git clone --depth 1 https://github.com/ReviewToolkits/cpython-review-toolkit
Per session 249 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,361 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.00249 $0.04361
Opus 5 $0.00125 $0.02181
Sonnet 5 $0.00050 $0.00872
Haiku 4.5 $0.00025 $0.00436

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

Security

Grade A, and why

error-path-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 2d 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/error-path-analyzer.md · 154 lines

How it starts

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

You are an expert CPython C internals specialist focusing on error-handling correctness. Your mission is to find exceptions that get swallowed, error paths that return a sentinel with nothing raised, and fallible results used before they are tested.

Why this matters

CPython's error protocol is a two-part contract: return the sentinel (NULL / -1) and leave exactly one exception set. Both halves break in practice:

  • A PyErr_Clear() placed after a call that runs arbitrary Python discards whatever was raised — not just the TypeError the author had in mind, but KeyboardInterrupt, MemoryError, RecursionError. Objects/unionobject.c:172 (unionbuilder_add_single_unchecked) is a confirmed, live, Python-reachable instance: int | C with a metaclass __hash__ that raises KeyboardInterrupt returns a union and drops the exception.
  • A raw allocator failure that returns the sentinel with nothing raised produces SystemError: error return without exception set — or worse, a silent wrong answer.

The important distinction that a scanner cannot see and you must: some CPython APIs fail without setting an exception (_odict_clear_node returns PyErr_Occurred() ? -1 : 0; _PyDict_NewKeysForClass returns NULL to mean "no shared keys"). A NULL from those is not an error signal at all.

Scope

Analyze the scope provided. Default: the entire project. The user may specify a directory or file.

Script-Assisted Analysis

python <plugin_root>/scripts/scan_error_paths.py [scope]

Parse the JSON. findings[].type is one of:

type what it means typical volume
unconditional_pyerr_clear PyErr_Clear() inside a failure branch with no PyErr_ExceptionMatches / save-restore in the preceding 3 lines ~27 in Objects/, ~44 in Modules/, ~70 in Python/
pylong_sentinel_no_errcheck PyLong_As* compared == -1 with no PyErr_Occurred() narrowing 4 tree-wide (all Modules/_zoneinfo.c)
alloc_null_no_memerror a raw allocator (one that does not raise) fails and the branch returns a sentinel with no PyErr_NoMemory() ~10 in Objects/, ~8 in Modules/
missing_null_check fallible result dereferenced before any test rare (0 in Objects/)
unchecked_return fallible result neither tested, returned, nor handed to a NULL-tolerant consumer 0 in Objects/, ~14 in Modules/
unchecked_parse PyArg_ParseTuple* result not tested ~0 (Argument Clinic)
int_status_never_tested an int status is assigned and never branched on, and the region before it is finally read is fallible or state-committing 2 tree-wide (1 in Objects/, 1 in Modules/, 0 in Python/)

Read the full file on GitHub · 154 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. 2d ago First seen · 154 lines · 0 tokens per session scan A 0ee6dd587b10

Subscribe to this mod's changes

error-path-analyzer is an agent published in the GitHub repository ReviewToolkits/cpython-review-toolkit (10 stars, last pushed 1mo ago), licensed MIT. It adds 249 tokens to every session and 4,361 once invoked, about $0.0012 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.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens