🎤Micdrop

Devtools: a Live Timeline of Each Turn

@micdrop/devtools adds a panel to your page that follows the call turn by turn. Each turn shows when the user spoke, what the speech to text heard, the tools the agent ran, the answer and the voice that read it, with a waterfall of where the silence went and what the turn consumed.

The devtools panel over an app, with four turns and their latency waterfalls

Install

Terminal window
npm install @micdrop/devtools

The panel reads what the client already receives: the state changes, the messages and the tool calls. For the latency of each step and the usage, the server also has to send its metrics:

import { forwardMetrics, MicdropServer } from '@micdrop/server'
const server = new MicdropServer(socket, { stt, agent, tts })
forwardMetrics(server)

Without them, each turn still gets the latency the client heard, from the end of the user speech to the first sound of the answer.

Add the panel

Load it in development only, so it never reaches your users:

import { Micdrop } from '@micdrop/web'
if (import.meta.env.DEV) {
const { mountDevtools } = await import('@micdrop/devtools')
mountDevtools(Micdrop)
}

mountDevtools() returns { element, timeline, unmount }. Its second argument takes open to start with the panel open, position (bottom-right or bottom-left) and container, the element to add it to.

In React, the component mounts the panel for as long as it is rendered:

import { Micdrop } from '@micdrop/web'
import { MicdropDevtools } from '@micdrop/devtools/react'
export function App() {
return (
<>
<YourApp />
{import.meta.env.DEV && <MicdropDevtools client={Micdrop} />}
</>
)
}

To keep its code out of the production bundle as well, load it with lazy(), as the advanced example does behind ?devtools.

The panel is a <micdrop-devtools> custom element, drawn in a shadow DOM: your styles leave it untouched and its own stay inside. Any framework can use it, after defineDevtoolsElement(), by setting its client property.

Read a turn

PartWhat it shows
HeaderWho opened the turn, whether the user cut it short, the model and the total silence, green under 800 ms and red past 1.5 s
WaterfallThe wait for the answer, step by step: stt, wait (a classifier for instance), llm up to the first token and tts up to the first voice. A realtime model shows as one model step. Every turn shares one scale, so a slow step stands out
Felt markThe latency the client heard, network and speaker buffer included, next to what the server measured
PhasesThe user speaking in blue, the voice of the assistant in green and a tick for each tool call, on the clock of the client
ExchangeThe transcript, struck out when the server cancelled it, each tool call with its parameters and output, and the answer, in italics when it was cut before its end
UsageAudio in and out, characters sent to the text to speech, tokens with the cached part, and how many messages the agent read

The header of the panel adds the call up: turns, median and p95 latency, interruptions, tool calls and tokens. The other tabs list the conversation and every raw event with its time since the start.

Export a call for a bug report

Copy puts the call on the clipboard as JSON and Export downloads it. The file holds every event, the turns built from them, a summary, the user agent and the page path. Open loads such a file back into the panel, to look at a call someone else recorded.

An export holds what was said during the call and the arguments of the tools. Read it before attaching it to a public issue.

A new call clears the panel, so an export holds a single call. Clear forgets the events whenever you like.

Build your own view

@micdrop/devtools/core holds the data model alone, without any DOM, so it runs in React Native and in Node as well:

import { Micdrop } from '@micdrop/client'
import { attachTimeline } from '@micdrop/devtools/core'
const { timeline, detach } = attachTimeline(Micdrop)
timeline.subscribe(() => {
for (const turn of timeline.turns) {
console.log(turn.key, turn.transcript, turn.metrics?.latency.total)
}
})

timeline.turns gives each turn with its transcript, answer, tool calls, waterfall and metrics, timeline.summary the figures of the call and timeline.toJSON() the export. In React, and in React Native, useMicdropTimeline(Micdrop) from @micdrop/devtools/react returns them and renders again on every event.

The client cuts a turn when the user starts speaking. The metrics of the server then pair with their turn by the order of the messages, which arrive in the order the server sent them, so the clocks of the two machines never need to agree.