Skip to content

Conversation

toubatbrian
Copy link
Contributor

No description provided.

from livekit.agents.llm import function_tool


class DtmfEvent(str, Enum):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

use enum to have strict tool schema instead of raw string



@function_tool
async def send_dtmf_events(
Copy link
Contributor Author

@toubatbrian toubatbrian Sep 23, 2025

Choose a reason for hiding this comment

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

For now I'll wait for ToolSet class: https://github.com/livekit/agents/pull/3296/files#diff-f443ca72981c01a0780b2742eef4232b4a313c99d36f462900034b138df2c016. And convert those function_tool into ToolSet class once done.

But the general idea is that we expose 2 tools in the toolsets, one allows pressing a single digit and the other one allows pressing a sequence (which may be a usage pattern so agent only need one tool call to handle multiple dtmf events)

Copy link
Member

Choose a reason for hiding this comment

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

Do we need 2 tools? The LLM could also just use a single element list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I think that also work

for event in events:
try:
code = dtmf_event_to_code(event)
await job_ctx.room.local_participant.publish_dtmf(code=code, digit=event.value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sending a sequence, not sure if we want to add a sleep between each. @theomonnom

Copy link
Member

Choose a reason for hiding this comment

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

No I don’t think we need to sleep

class DtmfAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions="You are a voice assistant that can press number on the phone to interact with the user or a IVR system.",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will improving the system message

@toubatbrian toubatbrian requested a review from longcw September 23, 2025 15:48
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.

2 participants