How do I know livekit has exhausted the max number...
# ask-ai
p
How do I know livekit has exhausted the max number of retries for a particular function tool?
t
Thanks for reaching out, Mario. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hello! Our team is operating on reduced capacity over the holidays, so our responses may be delayed. If your issue is critical/urgent, please react to your original message above with the ‼️ emoji and your issue will be escalated with our team. Happy Holidays!
Thanks — you're asking how to tell when LiveKit has exhausted max retries for a given function/tool. Here’s how to detect that, depending on the component: • Webhooks ◦ LiveKit stops retrying when it reaches the configured
MaxRetries
. After that no further delivery attempts occur. ◦ You can detect exhaustion by checking webhook delivery logs for a final failed attempt marked as "max retries reached" or by seeing no further attempts after the last retry interval (exponential backoff between
RetryWaitMin
and
RetryWaitMax
). ◦ Events may also be dropped if they exceed
MaxAge
(default 30s) or queue
MaxDepth
(default 200), which effectively ends retries. • Agent job dispatch ◦ A worker connection timeout of 10 seconds acts as a fail-fast. If the worker never connects within that window the job is considered failed — that indicates the retry/dispatch window was exhausted. • Client reconnections ◦ Automatic reconnect uses exponential backoff (0s, 2s, 4s, 8s, …) and gives up after 60 seconds. If reconnection attempts stop after ~60s, that means reconnection retries were exhausted. • Server-side HTTP calls ◦ Server SDK/CLI use
hashicorp/go-retryablehttp
. Retry exhaustion is when the library reaches its configured max attempts; check the request/response logs or the retryablehttp wrapper logs for a final failure indicating max retries reached. If you want, tell me: • Which specific function/tool you’re asking about (webhook, agent dispatch, client reconnect, or server HTTP request), and • Where you’re looking (LiveKit server logs, SDK logs, or webhook consumer logs). I’ll give exact log fields/messages and steps to locate them for that component. Sources: examples/survey | livekit/livekit_composite | DeepWiki | Agents Framework | livekit/livekit_composite | DeepWiki | client-sdk-swift | livekit/livekit_composite | DeepWiki | server-sdk-go | livekit/livekit_composite | DeepWiki
p
um... what about retries of function tool in python? how can I programatically capture that?
t
Thanks — you're asking how to detect, from Python code, when a LiveKit function tool has exhausted its retries. I don't have docs describing a built-in Python hook for function-tool retry exhaustion, so a couple quick clarifying questions so I can give a precise, runnable solution: 1. Which Python integration are you using for the "function tool"? ◦ LiveKit Python SDK, a custom function running on a webhook, AWS Lambda, or another runner? 1. How are retries currently implemented or configured? ◦ Is retrying handled by LiveKit (server-side), by a library like `retryablehttp`/`tenacity`, or by your own code? With those answers I can: • Show code to detect final failure (examples for
tenacity
, `requests`+`urllib3`/`retryablehttp` wrappers, or webhook handler patterns), or • Suggest a server-side/logging approach if retries are fully managed by LiveKit and not exposed to the Python process. Sources: examples/survey | livekit/livekit_composite | DeepWiki | server-sdk-ruby | livekit/livekit_composite | DeepWiki
p
I'm talking about agent function tool
t
Thanks — you're asking about detecting when an agent function tool in Python has exhausted retries. I’m responding to your point that this is an agent function tool. Short answer: agent function tools do not expose a built-in retry counter or an exhaustion callback you can read programmatically. The Agents framework handles retries internally at the session/job level, but you cannot query a max-retry event for a specific tool. What you can do: implement retries inside the tool so your code knows when max retries are hit. Example pattern:
Copy code
from livekit.agents import function_tool, RunContext, ToolError
import asyncio

@function_tool()
async def my_tool(self, context: RunContext):
    max_retries = 3
    for attempt in range(1, max_retries + 1):
        try:
            # replace with real operation
            result = await self._call_external_api()
            return result
        except Exception as e:
            if attempt == max_retries:
                # programmatic detection of exhausted retries
                await context.session.say("I've tried multiple times but cannot complete the request.")
                raise ToolError("Max retries exceeded after 3 attempts") from e
            await asyncio.sleep(2 ** (attempt - 1))  # exponential backoff
If you want, I can: • Customize that snippet for the specific API/library you call (requests, httpx, grpc, etc.), or • Show how to log/emit metrics or events when retries are exhausted so you can monitor them externally. Which would you prefer? Sources: Tool definition and use | LiveKit docs | Agents Framework | livekit/livekit_composite | DeepWiki