DEV Community

Mukunda Rao Katta
Mukunda Rao Katta

Posted on

I had 3,000 agent trace events in JSONL. My manager wanted them in Excel. One line.

Hermes Agent Challenge Submission: Build With Hermes Agent

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")
Enter fullscreen mode Exit fullscreen mode

Open run.csv in Excel or Google Sheets. Default columns:

timestamp, kind, name, lane, model, tokens_in, tokens_out, cost_usd, duration_ms, error
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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"])
Enter fullscreen mode Exit fullscreen mode

Get CSV as a string

result = export_csv(events)
print(result.csv_text)
# timestamp,kind,name,...
# 1716566401,llm_call,research-agent,...
Enter fullscreen mode Exit fullscreen mode

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")
Enter fullscreen mode Exit fullscreen mode

CLI

trace-export-csv run.jsonl out.csv
trace-export-csv run.jsonl out.csv --all
Enter fullscreen mode Exit fullscreen mode

What I actually do with the CSV

result = export_file("logs/run.jsonl", "analysis/run.csv")
Enter fullscreen mode Exit fullscreen mode

Then in the spreadsheet:

  • Filter error != "" to see all failures
  • Pivot on kind to see event type distribution
  • Sum cost_usd column for total run cost
  • Sort by duration_ms descending 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
Enter fullscreen mode Exit fullscreen mode

Repo: https://github.com/MukundaKatta/trace-export-csv

Top comments (0)