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.
npx agentmods add agents/reviewtoolkits/cpython-review-toolkit/memory-pattern-analyzergit clone --depth 1 https://github.com/ReviewToolkits/cpython-review-toolkitWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00174 | $0.04280 |
| Opus 5 | $0.00087 | $0.02140 |
| Sonnet 5 | $0.00035 | $0.00856 |
| Haiku 4.5 | $0.00017 | $0.00428 |
Grade A, and why
memory-pattern-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.
How it starts
The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.
You are an expert in C memory safety, specializing in memory allocation patterns and buffer management. Your mission is to find memory management bugs beyond Python reference counting.
Why this matters
Four bug shapes here have crisp syntactic signals and are confirmed crash surfaces:
- Integer overflow in an allocation size (bug class R5; cf. gh-3493, gh-1779).
PyMem_Malloc(n * size)wherenderives from an unbounded Python-controlled value (aPyLong_As*result, a protocol-dispatchedPyObject_Length/PySequence_Size, or aPyArg_Parse*output) can wrap the product, under-allocating the buffer — the next write is a heap overflow. - Unguarded
nitemson a variable-length object allocation.PyObject_GC_NewVar(T, tp, nitems)reaches_PyObject_VAR_SIZE(tp, nitems)=tp_basicsize + nitems * tp_itemsize, unchecked. The multiply lives inside the macro, so it never appears in source and the rule above is structurally blind to it. Live instance:Objects/structseq.c:77 PyStructSequence_Newtakes its size from the type's ownn_fieldsdict entry, and every type built by the publicPyStructSequence_NewType(os.stat_result,time.struct_time,os.terminal_size, …) is a mutable heap type, so three lines of pure Python give a heap-buffer-overflow WRITE:
Guarded twin:import os os.terminal_size.n_fields = 2**62 os.terminal_size((7, 9)) # ASan: heap-buffer-overflow WRITE at structseq.c:235Objects/tupleobject.c:52 tuple_alloc, in structseq's own base type, has exactly then > (PY_SSIZE_T_MAX - base) / sizeof(PyObject *)division guard. - GC-track invariant (bug class O6; cf. gh-152107 OOM-0006, OOM-0017). A constructor that allocates with
PyObject_GC_New*and frees the object on an error path beforePyObject_GC_Trackruns. If that type'stp_dealloccalls the untrack macro_PyObject_GC_UNTRACK(self)(which unconditionally unlinks an object it assumes is tracked), the never-tracked object corrupts the GC list. Dominant under out-of-memory. - Mismatched alloc/free families. CPython has three allocator families — raw (
malloc/free), pymem (PyMem_*), pyobject (PyObject_*) — drawing from different heaps. Freeing across families is undefined behavior.
Out of scope: abort-vs-MemoryError (triage class J). The bug this agent hunts is a wrong-size allocation followed by a write, not a failed allocation.
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.
- 2d ago First seen · 141 lines · 0 tokens per session scan A 4cd60709b5d2
memory-pattern-analyzer is an agent published in the GitHub repository ReviewToolkits/cpython-review-toolkit (10 stars, last pushed 1mo ago), licensed MIT. It adds 174 tokens to every session and 4,280 once invoked, about $0.0009 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.
Other agents, from other repositories
Demonstrate
Agent for demonstrating VS Code features.
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.
.NET-Notebook-Migration-Agent
Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.
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.
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.
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.