Hey, got a 401 for delete room (seems to have only...
# agents
m
Hey, got a 401 for delete room (seems to have only happened once, but wondering if there is an impacted service? all other rooms were deleting normally)
Copy code
2025-09-14T22:33:27.282860+00:00 | ERROR    | exception occurred while executing tool |
    {taskName=null, contact_id="321732f7-531a-4806-9129-a21751e9321d", 
    phone_number="+12542148445", exc_info="Traceback (most recent call last):
      File "/app/calltree_agent_framework/middleware/calltree_deco.py", line 142, in wrapper
        result = await asyncio.wait_for(_call(), _timeout_s_to_use) if _timeout_s_to_use is not
     None else await _call()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
        return await fut
               ^^^^^^^^^
      File "/app/calltree_agent_framework/middleware/calltree_deco.py", line 138, in _call
        return await fn(*args, **temp_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/app/calltree_agent_framework/agents/base_agent.py", line 510, in transfer_to_human
        await self.hangup_call()
      File "/app/calltree_agent_framework/agents/base_agent.py", line 427, in hangup_call
        await ctx.api.room.delete_room(
      File "/bundle/lib/python3.12/site-packages/livekit/api/room_service.py", line 108, in
    delete_room
        return await self._client.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/bundle/lib/python3.12/site-packages/livekit/api/twirp_client.py", line 129, in
    request
        raise TwirpError(
    livekit.api.twirp_client.TwirpError: TwirpError(code=unauthenticated, message=object cannot
     be found, status=401)", speech_id="speech_3599af9c979e"}
can provide room_id in dms 👀
r
401 is an auth problem. Check you LK keys
a
it has only happened 2x and we have taken tons of calls
r
ok, make sure you don't have an issue where LK keys or system clock is out of sync
a
is it OK to implement a retry here?
r
you can retry.
👍 1
But I am 99.9% sure this is a bug in your code with keys or the system clock is not accurate
a
LK keys seem good, system clock I am not sure, we are using serverless (Fargate) and I really haven't had an issue with that before (if there's an actual clock problem someone at EC2 tends to get paged)
where would there be a bug with the keys?
the keys allow us to connect to the room and are not changed
r
401 is an auth problem so the bug would be not sending the correct value
Next time it fails can you save the token and share the one you used
a
can you dive a bit and check on your side if it is an an actual auth problem?
r
401 is auth problem
if you are getting 401 it is an actual auth problem
a
yes I know the code is one for auth problems
r
I can look. Let me have to token you used and when it happened
Also the session id for when it failed
m
We're not logging any JWT or Session ID from AgentSessions -- should we be? Since we are always 1:1 we have been treating Room ID as the identifier -- is the room not enough to find the calls made to the Room service? It's just particularly odd that the same creds work for every other session (even other sessions on the same container which should rule out signing issues from clock sync). The creds live on the underlying task definition and our entrypoint throws if a required key is inaccessible based on config
r
I guess if you want to debug an auth problem you will need the credentials that failed so you can see why it failed.
> It's just particularly odd that the same creds work for every other session Agreed.
Start by base64 decoding them and make sure they have the permissions needed. Check the timestamps there for
nbf
and the valid until time. Then check the signature was correct
Here is a little tool that can help decode a JWT token: https://yepher.com/livekit/validate_token.html
In my experience with these things, assuming they have the required permissions the issue tends to be the
nbf
value.
If you have a failed token and the sessionID for when it failed I can try and help look at it.