I got a: `WARNING livekit.agents maximum numb...
# ask-ai
s
I got a:
WARNING  livekit.agents     maximum number of function calls steps reached
the agent reached the maximum tool call and never replied back. is that common? Also, if I ask the agent to perform a certain task it starts calling calls without ever noticing me what it's doing. Shouldn't it tell me before starting chaining tools? how do i do that?
t
Thanks for reaching out, Roman. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — that warning and the silence can definitely be confusing. I’ll explain what’s happening, why it’s relatively common, and give clear, practical ways to make the agent notify you before (and during) chained tool calls. Acknowledging your points • You saw:
WARNING livekit.agents maximum number of function calls steps reached
and then the agent stopped without replying. • You’d like the agent to tell you before it starts chaining tool calls so you know what it’s doing. What that warning means (brief) • The agent hit the default limit of consecutive tool calls in a single LLM turn (the default is 3). When that limit is reached, the agent stops making further tool calls and may not produce a final user-facing message if it hasn’t already generated one. This is by design to prevent infinite loops. Is this common? • Yes — it’s relatively common when a task requires multiple tool calls and the agent chains actions without first producing a verbal reply. The agent’s internal decision to call tools doesn’t automatically generate a user notification unless you instruct it to do so. What you can do right now (practical options) • Use any one or a combination of these changes to make the agent notify you and avoid abrupt silence: 1) Have the agent speak before performing long or chained work (preferred) • Add a short reply from the agent before the tool starts. Example pattern: ◦ When a tool starts, generate a reply like: "I’m going to run a few steps to do X. I’ll update you as I progress." • Implementation approach: ◦ In your tool wrapper or function definition, call the session’s reply-generation API before executing the heavier logic so the user sees immediate feedback. 2) Increase the maximum number of tool steps per turn • If your workflows legitimately need more than the default consecutive calls, increase
max_tool_steps
on the
AgentSession
to allow longer chains (for example, from 3 to 5). • Use this with caution — increasing it prevents premature stopping but does not by itself add user notifications. 3) Add periodic status updates during long-running chains • For lengthy or multi-step operations, schedule short status messages (e.g., “Working on step 2 of 4…”) at intervals or after key steps. Cancel the scheduled updates if the task finishes early. • This keeps the user informed and prevents the feeling of the agent being “stuck.” 4) Prompt-engineer the agent to announce actions • In the agent’s instructions, require it to state intent before calling tools and to summarize results afterward. Example instruction snippet: ◦ “Before calling external tools, tell the user what you will do and provide brief updates after each tool invocation.” Example (conceptual) code patterns • Notify before work:
Copy code
# inside your tool
await context.session.generate_reply(instructions="I'll start performing X now; this may take a moment.")
result = await _perform_task(...)
return result
• Increase max steps:
Copy code
session = AgentSession(
    ...,
    max_tool_steps=5
)
• Periodic status update pattern:
Copy code
status_task = asyncio.create_task(_speak_status_update(0.5))
result = await _perform_task(query)
status_task.cancel()
Recommended approach • Start by making the agent explicitly generate a short user-facing reply before calling tools (option 1). That gives immediate transparency with minimal changes. • If your tasks need more chained steps after that, raise
max_tool_steps
as a second step. • Add periodic updates for any operations that take noticeable time. If you want, I can: • Suggest a specific change tailored to your current tool definitions (paste one example tool or the agent’s instructions), or • Provide a short snippet you can drop into your code that will generate the “I’m starting X” message before any tool runs. Which would you prefer? Sources: Agent session | LiveKit Documentation | External data and RAG | LiveKit Documentation