Problem
agentrace stats --json writes both a human table and the JSON to stdout:
console.print(table)
if args.json:
print(json.dumps({...}))
So the actual output is a Rich-rendered table followed by a JSON object, on the same stream. agentrace stats --json | jq . fails. The CI smoke test does not catch this because it runs the command without piping it anywhere.
The wider version of the problem: --json exists only on stats. list, check, and show have no machine readable output at all. That is awkward for a tool whose README pitches check --strict as a CI gate, because the exit code is all a CI job can consume. You cannot post findings to a PR comment, write them to a report artifact, or filter them with jq.
Suggested approach
- Fix
stats --json first: when --json is passed, either suppress the table entirely or send it to stderr. Suppressing is the more conventional choice for a data flag. Decide, and say which in --help.
- Promote
--json to a top level flag on the parser rather than a per subcommand one, so agentrace --json check works uniformly.
- Define the JSON shape for each command and document it in the README, because once someone scripts against it, it is an interface:
list: an array of runs with id, description, duration, char counts, background, error.
check: an array of {run_id, description, findings: [{check, severity, message, evidence}]} plus a summary object. Finding is already a dataclass, so dataclasses.asdict covers most of it.
show: one run object including full prompt and result.
- Add a schema version field, for example
"schema": 1, so the shape can change later without silently breaking whoever scripted against it.
- Add tests that each command's
--json output parses cleanly with nothing else on stdout. That case is exactly what is broken today.
Done when
agentrace stats --json | jq . works.
- Every command supports
--json with a documented shape.
- The README documents the schema.
- Tests assert stdout is valid JSON and nothing else.
If you want to take this on, comment on the issue to claim it and it will be assigned. Please keep to a maximum of 2 open claims per person at a time so other contributors get a chance.
Problem
agentrace stats --jsonwrites both a human table and the JSON to stdout:So the actual output is a Rich-rendered table followed by a JSON object, on the same stream.
agentrace stats --json | jq .fails. The CI smoke test does not catch this because it runs the command without piping it anywhere.The wider version of the problem:
--jsonexists only onstats.list,check, andshowhave no machine readable output at all. That is awkward for a tool whose README pitchescheck --strictas a CI gate, because the exit code is all a CI job can consume. You cannot post findings to a PR comment, write them to a report artifact, or filter them withjq.Suggested approach
stats --jsonfirst: when--jsonis passed, either suppress the table entirely or send it to stderr. Suppressing is the more conventional choice for a data flag. Decide, and say which in--help.--jsonto a top level flag on the parser rather than a per subcommand one, soagentrace --json checkworks uniformly.list: an array of runs with id, description, duration, char counts, background, error.check: an array of{run_id, description, findings: [{check, severity, message, evidence}]}plus a summary object.Findingis already a dataclass, sodataclasses.asdictcovers most of it.show: one run object including full prompt and result."schema": 1, so the shape can change later without silently breaking whoever scripted against it.--jsonoutput parses cleanly with nothing else on stdout. That case is exactly what is broken today.Done when
agentrace stats --json | jq .works.--jsonwith a documented shape.If you want to take this on, comment on the issue to claim it and it will be assigned. Please keep to a maximum of 2 open claims per person at a time so other contributors get a chance.