AO
Back

Debug View: Merge User, Agent and Tool Chunks into One Transcript

Also reported as Merge Transcript Intervals

CodingOnsiteLast reported February 2026Low Frequency

Problem Overview

The round: one Sierra report thread, in which three candidates describe the same question. The poster calls it "debug view": time intervals with text, printed in order, much like merge intervals, with a follow-up about overlaps and gaps; they heard the same day that they were moving on to the onsite. Another candidate got it as an extra coding round after failing an onsite coding round, in four parts in 45 minutes. A third posted the sample input below. Part 1 is most of the code; Parts 2 to 4 are a few lines each. Four graded parts.

Input — the reported sample

A call between a user and an AI agent (the sample opens with "thanks for calling"), recorded as three lists of chunks. Each chunk is (start_ms, end_ms, text), and the lists are not sorted:

agent_chunks = [(3600, 4000, "inventory for you."), (0, 600, "Hi there, thanks for calling"), ...]
user_chunks = [(2300, 2800, "waterproof daypack for a short"), (1800, 2300, "Hi! I'm looking for a"), ...]
toolcall_chunks = [(4000, 4600, "search_inventory")]

Part 1 — merge the chunks into one transcript

def debug_view(agent_chunks, user_chunks, toolcall_chunks) -> list[str]:
  • Within each speaker, merge intervals: sort by start, and merge a chunk into the previous one when it starts at or before that one's end. The merged text is the chunk texts joined by a space.
  • Then merge the three speakers' turns into one list ordered by start time. Each turn is one line: "[start-end] speaker: text", with speaker user, agent or tool.
  • Under our format and merge rules, the sample gives [0-1800] agent: Hi there, thanks for calling Sierra Outfitters. What gear can I help you find today? and then [1800-3200] user: Hi! I'm looking for a waterproof daypack for a short hike.
  • Our validation rule: a chunk that ends before it starts, or is not a three-item tuple or list, raises ValueError.

Part 2 — mark interrupted agent turns

  • The user can interrupt the agent. Then the user and agent intervals overlap. Our rule: an agent turn is interrupted when a user turn starts strictly inside it.
  • That agent turn's text gets the suffix "... [INTERRUPTED]". The agent turn still prints first, since it started first.

Part 3 — show the agent's think-time gaps

  • The agent takes time to think, so there can be a gap between the end of a user turn and the start of the agent turn right after it.
  • When there is one, print a line "...[xx ms gap]..." between the two, where xx is the gap in ms.

Part 4 — p50 agent think time

def p50_think_time(agent_chunks, user_chunks, toolcall_chunks, nearest_rank: bool = False) -> float | None:
  • Return the p50 (median) of the gaps from Part 3, in ms, as a float. Return None when there is no gap.
  • With an even number of gaps, the default is the mean of the two middle gaps. nearest_rank=True takes the lower of the two instead.

Notes: the four parts and the reported strings "... [INTERRUPTED]" and "...[xx ms gap]..." come from the reports. These are ours: the names and signatures of debug_view and p50_think_time, the line format, joining text with a space, merging only touching or overlapping chunks, ties at the same start going user, agent, tool, the ValueError rule, marking an interruption only when the user starts inside the agent turn, keeping an interrupted turn's full text, marking gaps only from a user turn to the next agent turn, and for p50 the even-count rule, the nearest_rank flag, returning None with no gaps, and not counting gaps of zero. Ask about each one.

What Reports Emphasize

What the reports say: very close to merge intervals, and not hard. Four parts in 45 minutes; Part 1 is most of the code and the other three are a few lines each, so do not panic. One candidate got it as an extra coding round after failing an onsite coding round.

Common mistakes (ours, not reported): merging across speakers before merging within each speaker; forgetting that the chunks arrive unsorted; treating chunks that touch end to start as separate turns; formatting strings in Part 1 and parsing them back later; crashing on an empty gap list in Part 4.

Edge cases to test (ours): the reported sample (no overlaps, no gaps); a same-speaker pause; overlapping chunks of one speaker; a user who starts exactly when the agent stops; an agent who starts while the user is still talking; an even number of gaps for p50; no gaps at all.

Alternative approaches (ours): a single heap merge of the three sorted per-speaker lists instead of one combined sort; for Part 2, sort the user start times and binary-search each agent turn.

Practice

Write your own against 14 test cases, or read the worked solution — approach, complexity, and code that runs.
Did this match your interview?

If you have had this round, tell us how close this page was. It is how we keep the pages accurate.

Sierra AI · Coding · Reported 1× across candidate reports
Is this helpful?