Repository navigation
Add dispatch collect-agent-failures - #309
Merged
thrawn01 merged 6 commits intoNov 21, 2026
Merged
Conversation
Reads Claude Code transcripts over a window and prints tool failures grouped by signature, permission denials, subagent denials with whether the final report mentions them, and files edited 5+ times, as Markdown or JSON.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Finding where agents went wrong in the past week means running
~/.claude/retros/pattern-mining/datamine.pyby hand. That script lives outside the repo, and nothing tests it. This PR adds the script's tool-failure and denial tables to dispatch as a Go command that needs no AI. It makes the same rows from the same Claude Code transcripts. ENG-872 adds the PR history tables and ENG-873 runs it on a schedule.Fixes ENG-871
Surfaces
Command
dispatch collect-agent-failures [--from TIME] [--to TIME] [--json]It prints a Markdown report on stdout covering one window of time, by default the last 7 days. The report holds four tables of facts and draws no conclusions:
Flags and inputs:
--todefaults to now, and--fromdefaults to 7 days before--to. Both take the formatsdispatch replaytakes. A bare date such as2026-11-13means the start of that day in local time.--jsonprints the same rows as JSON instead of Markdown.~/.claude/projects, or from$CLAUDE_CONFIG_DIR/projectswhen that variable is set. Bash deny rules come fromsettings.jsonandsettings.local.jsonin the same config directory.Here is the report for a small made-up week. Two
go testcalls fail the same way, and a deny rule blocks a subagent'sgit push, which its final report never mentions:--jsonprints the same rows. The keys come from the script'sdata.json, plusfrom,to,skipped_sessionsandtranscript_files:{ "from": "2026-11-14T00:00:00-06:00", "to": "2026-11-20T00:00:00-06:00", "tool_failures": [ { "signature": "...", "count": 2, "sessions": 1, "repos": "shop", "first_seen": "...", "last_seen": "...", "example": "..." } ], "tool_failures_dropped_singletons": { "signatures": 0 }, "permission_denials": [ ... ], "subagent_denials": [ ... ], "repeated_edits": [], "skipped_sessions": [], "transcript_files": 2 }A transcript the command cannot read prints
dispatch: skipped <why>on stderr. The run still exits 0.Behavior changes
Before this PR, dispatch had no such command, and the tables came only from the Python script. I ran both on the same window,
--from 2026-11-13T00:00:00Z --to 2026-11-20T22:02:20Z, over 2,899 real transcript files (3 GB). The 52 tool failure signatures, 20 permission denials, 159 subagent denials and 16 repeated-edit rows matched the script row for row. Sections 1 through 2b of the Markdown matched byte for byte, apart from the footer line below. The run took about 11 seconds.Concerns and risks
collect-agent-failuresand its flags because the user chose them in chat ("go with collect-agent-failures"). They consideredpatterns,retroandreflecttoo, and leftreflectfree for an AI step under ENG-868.agent_failures.go, so dispatch's source and usage text never contain it. ENG-873 may want a real marker once dispatch runs the miner."timestamp":"on a line, which can be an older time nested in a tool input. On disk, 15 of about 232,000 records have such a nested time.Dropped N signatures seen once.The script's version addedholding N failures, and that number always equalled N. The JSON drops itsfailuresfield for the same reason.toolDenialKindis ignored. All 772 values on disk are strings.#that starts a word begins a comment through the end of its line. The script opened a quote at the apostrophe in# don't, and so lost every command after that comment."${DISPATCH_BIN:-dispatch}" ask, reads as$, so every worker'sdispatch askfailure groups underBash | $ | …. A subagent id that holds a digit becomes<sha>, not<id>. Fixing either one changes rows and breaks the match with the script.\bmatches ASCII only, but Python's also matches other Unicode letters. A placeholder next to a non-ASCII letter, as inüber.go, can normalize differently from the script. On the reference week no row differed.~/Development, then one under home, then(temp dir). It does not read the repos in dispatch's config, as the script didn't either.