This is a submission for the Hermes Agent Challenge.
After running my Hermes research agent across 50 different literature review tasks, I had a JSONL file with 3,000 events and 18 fields per event. The stakeholder wanted to see cost and error patterns in Excel. I needed to get from JSONL to CSV without writing a custom parser.
That's trace-export-csv.
One line
from trace_export_csv import export_file
result = export_file("logs/run.jsonl", "analysis/run.csv")
print(f"Exported {result.row_count} rows")
Open run.csv in Excel or Google Sheets. Default columns:
timestamp, kind, name, lane, model, tokens_in, tokens_out, cost_usd, duration_ms, error
Field auto-detection
Different agent frameworks name the same fields differently. The library auto-detects all common variants:
| CSV column | JSONL keys tried |
|---|---|
kind |
kind, type, event_type |
tokens_in |
tokens_in, input_tokens, prompt_tokens |
tokens_out |
tokens_out, output_tokens, completion_tokens |
cost_usd |
cost_usd, cost, price_usd, usd |
name |
name, step, tool, tool_name |
error |
error, err, exception |
If your JSONL uses any of those variants, the column is populated automatically.
Include every field
result = export_file("run.jsonl", "out.csv", include_all=True)
Takes the union of all keys across all events and adds them as columns. Missing values become empty cells.
Include specific custom fields
result = export_csv(events, "out.csv", extra_fields=["run_id", "sub_task", "worker"])
Get CSV as a string
result = export_csv(events)
print(result.csv_text)
# timestamp,kind,name,...
# 1716566401,llm_call,research-agent,...
No file written. Useful for piping, display, or writing to a custom destination.
From events in memory
from trace_export_csv import export_csv
events = load_my_events() # list of dicts
result = export_csv(events, "out.csv")
CLI
trace-export-csv run.jsonl out.csv
trace-export-csv run.jsonl out.csv --all
What I actually do with the CSV
result = export_file("logs/run.jsonl", "analysis/run.csv")
Then in the spreadsheet:
- Filter
error != ""to see all failures - Pivot on
kindto see event type distribution - Sum
cost_usdcolumn for total run cost - Sort by
duration_msdescending to find the slowest events
None of this requires any code — just standard spreadsheet operations on a well-structured CSV.
Zero dependencies
Standard library only: csv, json, io, pathlib, dataclasses. No third-party packages.
pip install trace-export-csv
Top comments (0)