#35Aggregate trace eventsEasyML System DesignAgentic AI
Aggregate trace events
Background
The Tracer logs every meaningful action as a TraceEvent with an agent_id and an event type. tracer.summary() starts by counting events grouped by (agent_id, event):
counts = {}
for e in events:
key = (e["agent_id"], e["event"])
counts[key] = counts.get(key, 0) + 1
Problem statement
Implement trace_counts(events) returning the {(agent_id, event): count} dict.
Input
events— list of event dicts, each with"agent_id"and"event"keys.
Output
Returns a dict mapping each (agent_id, event) tuple to its number of occurrences.
Examples
Example 1
Input: [{"agent_id": "exec_1_0", "event": "llm_call"},
{"agent_id": "exec_1_0", "event": "llm_call"},
{"agent_id": "exec_1_0", "event": "search"}]
Output: {("exec_1_0", "llm_call"): 2, ("exec_1_0", "search"): 1}
Constraints
- Key by the
(agent_id, event)tuple. - Count occurrences; empty input →
{}.
Notes
- This grouping is the backbone of the summary table — one row per
(agent, event)pair.
Python
Loading...
▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.
- •Reference example: groups by (agent, event)
- •Sample: empty input yields an empty dict
- •Reference example: multiple agents counted separately