Skip to content

Conversation

@1egoman
Copy link
Contributor

@1egoman 1egoman commented Oct 30, 2025

This should hopefully make the agents sdk more robust to cases like a local agent server being terminated, a hosted agent leaving a call due to it being connected longer than the drain threshold, etc.

It still is an open question how we can / should disambiguate between purposeful agent disconnects and outright crashes. It doesn't seem like today there is enough metadata to do this, so right now I am assuming all non user triggered disconnects to be of the "crash" variety.

I think if the metadata to disambiguate this properly becomes available, then it would be worth making this difference clear somehow - maybe purposeful disconnects go into disconnected (and maybe there's an event that is emitted that a user can tap into and reset their app's connection state since right now that would be managed out of band), and crashes retain this failed status with the reason.

This should hopefully make the agents sdk more robust to cases like a
local agent server being terminated, a hosted agent leaving a call due
to it being connected longer than the drain threshold, etc.

It still is an open question to a degree how we can / should
disambiguate between purposeful agent disconnects and outright crashes.
It doesn't seem like today there is enough metadata to do this so right
now I am assuming all non user triggered disconnects to be of the
"crash" variety.
@1egoman 1egoman requested review from lukasIO and pblazej October 30, 2025 08:58
@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

🦋 Changeset detected

Latest commit: 1087076

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@livekit/components-react Patch
@livekit/component-example-next Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

size-limit report 📦

Path Size
LiveKitRoom only 6 KB (0%)
LiveKitRoom with VideoConference 32.23 KB (0%)
All exports 42.62 KB (-0.07% 🔽)

@1egoman 1egoman marked this pull request as ready for review October 30, 2025 09:03
};
}, [room]);

// If the agent participant disconnects in the middle of a conversation unexpectedly, mark that as an explicit failure
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to rethink the disambiguation here, IMO this is fine for single agent use case (no "handoff", (re)joining, etc.)

@pblazej
Copy link

pblazej commented Oct 31, 2025

Don't wanna repeat myself: either going deeper with this or removing absent agent from the picture and moving this problem to the consumer. I'm fine with both, we just need to make sure that we may not be able to cover/predict all cases in the 1st approach.

@1egoman
Copy link
Contributor Author

1egoman commented Nov 12, 2025

Digging around in the python agents sdk, I found that there is a mechanism used to indicate whether it shutting down intentionally or not to the SFU via a reason parameter in an Exiting protobuf message, more info here: https://github.com/livekit/agents/blob/1a6bd41477c29f38f9619cf4c33006d88f9a66f5/livekit-agents/livekit/agents/ipc/job_proc_lazy_main.py#L286. Just wanted to note this down here since it might be related. However, I'm not sure if there's a way that other clients can actually get access to this right now. 🤔

Copy link

@pblazej pblazej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the discussion(s), let's treat disconnection as unconditional failure for now 👍

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@1egoman 1egoman merged commit 12b69cb into main Nov 13, 2025
6 checks passed
@1egoman 1egoman deleted the add-participant-unexpected-disconnect-failure branch November 13, 2025 06:46
@github-actions github-actions bot mentioned this pull request Nov 12, 2025
pblazej added a commit to livekit/client-sdk-swift that referenced this pull request Nov 13, 2025
- Adds more computed `is_` props to the (private for now) agent state
  - JS livekit/components-js#1231
- `buffering` state was already handled inside the `.connecting` enum
case (associated value is less error-prone)
- Adds disconnected == failed concept
  - JS livekit/components-js#1228
- Checks actual dispatch response when waiting for the agent
  - JS livekit/components-js#1226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants