#36Run totals from the traceEasy

Run totals from the trace

Background

The summary footer reports three run-level totals. An event counts as an LLM call if its type is any of llm_call, plan, synthesise, or critic_verdict (all of which invoke the model); searches and attempts are counted by their own event types.

Problem statement

Implement trace_totals(events) returning (total_llm, total_searches, attempts).

Input

  • events — list of event dicts with an "event" key.

Output

Returns a tuple:

  • total_llm — events whose type is in {"llm_call", "plan", "synthesise", "critic_verdict"},
  • total_searches — events of type "search",
  • attempts — events of type "attempt_start".

Examples

Example 1

Input:  [{"event": "plan"}, {"event": "llm_call"}, {"event": "search"},
         {"event": "attempt_start"}, {"event": "critic_verdict"}]
Output: (3, 1, 1)

Explanation: LLM = plan + llm_call + critic_verdict = 3; searches = 1; attempts = 1.

Constraints

  • total_llm sums the four model-invoking event types.
  • total_searches counts "search"; attempts counts "attempt_start".

Notes

  • "Total LLM calls" is usually higher than people expect — planning, synthesis, and every critique each cost a call.
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: mixed events
  • Sample: empty input yields zeros
  • Reference example: synthesise counts as an LLM call