agent-coroner
Artifact contracts, silent-failure detection, and LLM autopsy reports for unattended AI agents.
Your cron-scheduled agent ran fine — exit code 0 — but the weekly report it was supposed to write never appeared. Nothing alerted you. That's a silent failure, and it's the failure mode of unattended agents. agent-coroner watches the artifacts your jobs promise to produce, notifies you when a promise is broken, and (optionally) dispatches a read-only Claude "coroner" to write a postmortem explaining why.
How it works
- Contracts — declare what each job must produce (
contracts.yaml) - Checker — a fast, deterministic, LLM-free check: file exists, fresh enough, big enough, passes your verify command. Run it from cron / Task Scheduler.
- Autopsy — only when a contract is violated,
claude -pis launched read-only (Read,Grep,Glob) to diagnose the logs and write a 4-section postmortem (facts / hypotheses / verification steps / prevention). If the autopsy itself fails, the violation notification still goes out — detection never depends on the LLM.
No self-healing by design: the coroner examines the scene, it never touches it.
Install
uv tool install agent-coroner # or: pip install agent-coroner
Requires the claude CLI on PATH only for autopsies; check/status/unread work without it.
Quick start
contracts.yaml:
jobs:
weekly-report:
schedule: "FRI 08:30"
grace_minutes: 60
artifacts:
- path: "reports/weekly-*.md"
max_age_hours: 192
min_bytes: 500
logs: "run.log"
Run it before the artifact exists (or after it's gone stale) and the checker
reports a missing violation with a non-zero exit code:
$ coroner check --config contracts.yaml --no-autopsy
[coroner] 1 violation detected
- weekly-report / reports/weekly-*.md: missing (no file matches 'reports/weekly-*.md' under <contracts-dir>)
[coroner] 1 violation detected
- weekly-report / reports/weekly-*.md: missing (no file matches 'reports/weekly-*.md' under <contracts-dir>)
$ echo $?
1
(The message appears twice here because no notify command is configured: the
checker prints its own progress line, then falls back to printing the same
message a second time as the "notification". Set notify — see below — to
route it somewhere else instead of stdout twice.)
Once reports/weekly-*.md exists, is fresh, and clears min_bytes, the same
command prints weekly-report: ok and exits 0.
Register coroner check on a schedule:
schtasks /create /tn "coroner-check" /tr "coroner check --config C:\path\to\contracts.yaml" /sc daily /st 09:00
*/15 * * * * coroner check --config /path/to/contracts.yaml >> /var/log/coroner.log 2>&1
Contract reference
lang— top-level,"en"(default) or"ja"— language of autopsy postmortem section headers. Any other value raises a config error at load time.jobs.<name>— one entry per unattended job; the key is the job name used in state, notifications, and postmortem filenames.schedule— free-text metadata only (e.g."FRI 08:30"), not parsed or enforced by the checker; it exists for humans and for the autopsy prompt's job-definition context.grace_minutes— added tomax_age_hours(as minutes) before an artifact counts as stale. Default0.workdir— directory artifact/log globs are resolved against. Default: the directory containingcontracts.yaml.artifacts— list of rules, each checked independently; a job can have any number:path— a glob relative toworkdir; the newest matching file (by mtime) is evaluated.max_age_hours— if set, the newest match's age (plusgrace_minutes) must not exceed this or the artifact isstale. Omit to skip the freshness check.min_bytes— minimum file size in bytes; below this the artifact istoo_small. Default1.verify— optional shell command run against the newest match;{path}is substituted with the file's full path before the command runs viashell=Trueinworkdir. A non-zero exit is averify_failedviolation. On Windows, quote it — an unquoted{path}containing spaces breaks the command line: useverify: "python check.py \"{path}\"", notverify: "python check.py {path}".- Violation types in order of the check:
missing→stale→too_small→verify_failed.
logs— optional glob for the job's log file; only used to build the autopsy prompt's log-tail evidence, not checked itself.notify— optional shell command run viashell=Truewhen a violation fires. Two substitution tokens, mutually compatible:{message}— the whole notification text flattened to one line: double quotes become single quotes, newlines become"; ". Fragile for anything beyond a simple one-liner.{message_file}— the full, unflattened, multi-line message is written to a temporary UTF-8 text file and this token is replaced with that file's path; the file is deleted after the notify command runs. This is the reliable way to pass a multi-line report through a shell command, e.g.powershell -NoProfile -Command "Get-Content -Raw '{message_file}' | Write-Host".- If
notifyis omitted, the message is printed to stdout instead.
Claude Code plugin
/plugin marketplace add Chikoku-NEKO/agent-coroner
/plugin install agent-coroner@agent-coroner-marketplace
/coroner-status— runscoroner statusand summarizes which jobs are ok, which have violations, and their recent ok-rate; tells you touv tool install agent-coronerif the CLI isn't found./autopsy <job-name>— runscoroner autopsy --job <job-name>on demand and presents the resulting postmortem's four sections, or reports that the job's contract is currently satisfied.- A
SessionStarthook runscoroner unreadat the start of every Claude Code session so unread postmortems (any generated since your last acknowledgment) surface automatically instead of sitting silently in the postmortems directory.
Exit codes / Security notes / License
- Exit codes:
0= all contracts satisfied,1= one or more violations (or a job's check crashed),2= config error (bad/missingcontracts.yaml, unknown--job). verifyandnotifyare user-defined shell commands executed withshell=True— only point--configat contract files you trust. A maliciouscontracts.yamlcan run arbitrary commands on your machine.- MIT License — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_coroner-0.1.0.tar.gz.
File metadata
- Download URL: agent_coroner-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a744df022833399183bad185039d09424a46a6ccdc900cfcee13b6e48f78c9
|
|
| MD5 |
39068a83afa6aa44632f9985351d2b31
|
|
| BLAKE2b-256 |
705c59b20301dd229b6f54c4e90e9f377ea088ae00c10de37a3d871b33081c93
|
File details
Details for the file agent_coroner-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_coroner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b66e2464810696a642fee02c7ecaa2e8331ba952074e4c92ae11dfbf1cb63aea
|
|
| MD5 |
033f38868fe7fa076a983c34a3ba1765
|
|
| BLAKE2b-256 |
37d25123cb7672673640682f331a01a8a8499fab10ce5db262ec515803dbe9da
|