Skip to content
mentoor

Topic 5 of 5 · 5 min read

Tool calls and state during live conversations

Goal: Design the tool-call flow of a voice agent so slow lookups keep the caller informed and no booking or payment happens without a spoken confirmation.

During a call, a slow tool must not leave silence, and any action with side effects must wait for a spoken yes from the caller.

Check yourself · 1 of 3

A voice agent can cancel a customer's subscription. What is the safest design?

Choose one answer

Why it matters

On a screen, a spinner explains a two-second wait. On a phone line, two seconds of silence sounds like a dead call. And a voice agent that books, cancels or charges on a misheard word does real harm: speech recognition mishears names, dates and amounts.

How to design the flow

  1. Say something first. Before a lookup that may take over a second, have the agent give short filler ("Let me check that for you"). Do it in the agent's instructions or as a scripted line from your code, and keep it short so the caller can still interrupt.
  2. Separate reads from writes. Looking up an order is safe to run immediately. Booking, payment and cancellation are not.
  3. Confirm writes aloud. Read back the details in the caller's words: "Thursday at 3 pm with Dr. Rao, correct?" Run the tool only after a clear yes. Enforce this in code, not only in the prompt: the tool takes a confirmed value that your server sets from the caller's reply, or refuses to run.
  4. Make tools asynchronous where possible. For a long job, return "started" at once, let the conversation continue and report the result when ready. Cancel the job if the caller changes their mind.
  5. Keep the session small. Long calls grow context and cost. Summarise old turns, drop large tool results after use and plan for the session time limit your vendor documents, with a reconnect that restores a short summary.

Before and after

// Weak: the model can book on its own say-so
tools.book_slot = async ({ doctor, time }) => api.book(doctor, time);
// Better: server checks the confirmation state
tools.book_slot = async ({ doctor, time }) => {
  if (!state.pendingBooking || !state.pendingBooking.confirmed) {
    return { error: "not_confirmed", say: "Read the details back and ask for a yes." };
  }
  return api.book(state.pendingBooking.doctor, state.pendingBooking.time);
};

What goes wrong

  • Filler on every call. "One moment" before a 100 ms lookup is just noise.
  • Confirmation in the prompt only. The model can skip it. Put the gate in code.
  • Confirming something the caller did not hear. If an interruption cut the read-back, the "yes" may refer to nothing.
  • Letting long calls grow forever. Cost climbs and the model loses early instructions.

Examples

Confirm before booking

Caller: "Book Thursday at three." Agent: "Thursday 3 pm with Dr. Rao, shall I book it?" Caller: "Yes." Only then does the server flip confirmed to true and let the booking tool run. If the caller says "no, Friday", the pending booking is replaced and nothing has been written.

Trimming a long call

At minute twelve of a support call, the context holds a 400-line order history that was needed only once. The server replaces it with a two-line summary and keeps the last few turns verbatim, so cost and drift stay down for the rest of the call.

Key points

  • Give short filler speech before a slow tool call so the caller does not hear dead air.
  • Read-only tools can run immediately; tools with side effects need a spoken read-back and a clear yes first.
  • Enforce confirmation in server code, because a prompt rule can be skipped by the model.
  • Long jobs should return at once and report later, and be cancelled if the caller changes their mind.
  • Summarise old turns and drop large tool results so long calls stay cheap and within session limits.

Common mistakes

  • Adding filler before every lookup, including ones that return instantly.
  • Relying on the system prompt alone to require confirmation.
  • Counting a "yes" as confirmation when an interruption cut off the read-back.
  • Letting the context grow for the whole call until cost climbs and early instructions are forgotten.

Check yourself · 2 of 3

A lookup takes about three seconds, and callers think the line has dropped. What helps most?

Choose one answer

Check yourself · 3 of 3

Why keep context small over a long voice call?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic