cd /news/ai-agents/different-agent-frameworks-log-input… · home topics ai-agents article
[ARTICLE · art-16908] src=dev.to pub= topic=ai-agents verified=true sentiment=· neutral

Different agent frameworks log 'input_tokens' differently. Here's the fix.

A developer created trace-field-normalize, an open-source Python library that standardizes inconsistent field names across different agent frameworks. The tool maps variants like `input_tokens`, `prompt_tokens`, and `tokens_prompt` to a single canonical `tokens_in` field, and supports custom field mappings with optional preservation of original names. Built with only Python standard library dependencies, the library reads and normalizes trace data line by line from JSONL files without modifying source events.

read2 min publishedMay 28, 2026

This is a submission for the Hermes Agent Challenge.

I run agents on three different frameworks. Each one logs differently. One uses input_tokens

. Another uses prompt_tokens

. A third uses tokens_prompt

. My trace analysis code had to handle all three. Every new framework meant another alias to add everywhere.

That's trace-field-normalize

.

from trace_field_normalize import normalize_event

event = {"input_tokens": 42, "latency_ms": 350, "model_id": "claude-sonnet-4-5"}
result = normalize_event(event)

Unknown fields pass through unchanged. Nothing is dropped.

from trace_field_normalize import normalize_file

events = normalize_file("raw_traces.jsonl", "normalized.jsonl")

Reads the source line by line, normalizes each event, writes to dest. Blank lines are skipped.

Canonical Variants
tokens_in
input_tokens , prompt_tokens , tokens_prompt
tokens_out
output_tokens , completion_tokens , tokens_completion
cost_usd
cost , price_usd , usd , price
duration_ms
latency_ms , elapsed_ms , duration , latency
kind
event_type , type , event_kind
name
step , tool , tool_name , function_name
error
err , exception , error_message
model
model_id , model_name
lane
worker , agent_id , thread
timestamp
ts , time , created_at , event_time
from trace_field_normalize import FieldMap, normalize_event

fm = FieldMap(
    {"score": ["rating", "confidence"]},
    include_defaults=True,  # keep the built-in map too
)

event = {"rating": 0.95, "input_tokens": 100}
normalize_event(event, fm)

include_defaults=False

gives you a clean slate.

If the event already has the canonical name, variants are left alone:

event = {"tokens_in": 99, "input_tokens": 42}
normalize_event(event)
normalize_event({"ts": 1700000000}, keep_original=True)

Useful when downstream code still uses the old name.

from trace_field_normalize import normalize_events

events = normalize_events(raw_event_list)

Returns a new list. Originals are not modified.

Standard library only: json

, dataclasses

, pathlib

. Nothing else.

git clone https://github.com/MukundaKatta/trace-field-normalize
cd trace-field-normalize && pip install -e .
── more in #ai-agents 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/different-agent-fram…] indexed:0 read:2min 2026-05-28 ·