agents icon indicating copy to clipboard operation
agents copied to clipboard

lk agent simulate: spurious "Agent did not respond within 60.0s" on turns the transcript shows were answered (text-mode, Beta simulator)

Open Herzpraxis opened this issue 4 months ago • 3 comments

Summary

Text-mode simulations (lk agent simulate --scenarios …) intermittently fail with Agent did not respond within 60.0s on turn N even though the captured transcript for the same run shows a complete, well-formed conversation — including the agent's reply on the allegedly silent turn, the final booking confirmation, and the farewell. The agent-side log shows no pending work at that moment: the session closes with reason: user_initiated, and the session report uploads normally.

Environment

  • livekit-agents 1.6.7 (Python 3.14), plugins: openai/azure 1.6.7
  • LiveKit CLI 2.18.2, LiveKit Cloud project (eu)
  • Agent architecture: single Agent, all tools are strict single-turn function tools (no AgentTasks, nothing outlives a turn); LLM is Azure OpenAI chat with parallel_tool_calls=False
  • Simulations run in text mode (no STT/TTS/VAD)

Observed behaviour

Across ~20 runs on two days (12-scenario and 15-scenario suites, run both locally spawned and cloud-to-cloud):

  • 3–11 of the jobs per run fail with Agent did not respond within 60.0s on turn N; N varies uniformly (turns 3–11) and is not correlated with any scenario, tool, or prompt. Worst observed: 11 of 15 jobs failed this way in a single run with --concurrency 2 and zero provider rate-limit errors, while every one of the 15 transcripts was complete and every end-state assertion passed.
  • For every such failure, the transcript in the same output contains the agent's response on turn N and the conversation continues to a clean end.
  • The agent worker log for the affected room shows normal conversation_item_added events, then session closed {"reason": "user_initiated"} and a successful report upload — no error, no hung task, no retry.
  • The same suites pass their end-state assertions (bookings/requests created via on_simulation_end) in every completed conversation.

What we ruled out

  • Long-running tools: our final architecture was rebuilt so no tool spans a turn, after reading remote_session.py — we understand the contract as "the simulator calls interrupt(force=True) before each user turn and waits for session.run() to complete". Our agent satisfies this.
  • Model latency: the failures also occur on turns whose reply is visible in the transcript within seconds.
  • Rate limits: runs without any 429s still show the same distribution.

Expected

A turn that the transcript records as answered should not be scored as "did not respond within 60.0s".

Repro

We can share scenario files and full CLI output/agent logs privately if helpful. A minimal public repro is hard because the failures are probabilistic (~25–40 % of jobs per run) — happy to run instrumented builds.

Herzpraxis avatar Aug 01 '26 07:08 Herzpraxis

Currently working on this issue @Herzpraxis

samanyugoyal2010 avatar Aug 02 '26 09:08 samanyugoyal2010

We just merged https://github.com/livekit/agents/pull/6781, let me know if you're still able to reproduce the issue

theomonnom avatar Aug 11 '26 05:08 theomonnom

This follows up on @theomonnom's question above. #6781 shipped in [email protected]. Two of its tests cover the "transcript shows a reply, but the simulator timed out" pattern in this issue. I ran both against remote_session.py from just before the merge, and again against the merge commit:

  • test_aclose_flushes_the_response_of_an_inflight_request: before, the caller gets TimeoutError because shutdown cancels the handler before its response goes out. After, it passes.
  • test_room_transport_raises_instead_of_dropping_the_message: before, a failed send is only logged as a warning and the response is dropped (DID NOT RAISE RuntimeError). After, it passes.

remote session tests before/after #6781

As the #6781 caveats say, this does not guarantee delivery. A response send that fails mid-conversation still ends in a caller timeout, though the host now logs error handling session request with the request_id. So what remains open is the rate.

@Herzpraxis, on 1.6.10 or later, do your 12- and 15-scenario suites still show spurious Agent did not respond within 60.0s failures? If they do, an error handling session request line near the failing turn would show whether this is the remaining send-failure path or a different cause.

Repro
git checkout 3568970323
P=livekit-agents/livekit/agents/voice/remote_session.py
git show 3568970323^:$P > $P
uv run pytest tests/test_remote_session.py -k "aclose_flushes or raises_instead_of_dropping"
git checkout -- $P
uv run pytest tests/test_remote_session.py -k "aclose_flushes or raises_instead_of_dropping"

I ran this with a current main environment pointed at the 3568970323 tree (PYTHONPATH=livekit-agents), not with a fresh uv sync at that commit. Script used for the recording: demo-6661.sh

Scope: these are unit tests with fake transports. I did not run lk agent simulate, so I can't speak to the 25–40% rate.

himanshumehta avatar Nov 03 '26 19:11 himanshumehta