#15Find the bottleneck executorMediumML System DesignAgentic AI
Find the bottleneck executor
Background
The payoff of the trace: spotting the outlier. One executor that made 6 LLM calls while the others made 2 is the bottleneck — it's where the system spent its effort. You find it by counting llm_call events per agent_id and taking the max.
Problem statement
Implement find_bottleneck(events) returning the agent_id with the most llm_call events.
Input
events— list of event dicts with"agent_id"and"event"keys.
Output
Returns the agent_id (string) with the highest llm_call count. Ties break alphabetically (smallest agent_id). Returns None if there are no llm_call events.
Examples
Example 1
Input: exec_1_2 has 3 llm_call events, exec_1_0 has 1
Output: "exec_1_2"
Example 2 — no llm_call events
Input: [{"agent_id": "orchestrator", "event": "plan"}]
Output: None
Constraints
- Count only events with
event == "llm_call", grouped byagent_id. - Return the agent with the max count; ties → smallest
agent_id. - No
llm_callevents →None.
Notes
- This is "debugging by measuring": instead of guessing which agent is slow, the trace names it.
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: highest llm_call count wins
- •Sample: no llm_call events -> None
- •Example: ties break by smallest agent_id