Skip to content

feat(beta/tools): add speak_to_ivr tool auto-injected with ivr_detection#5399

Open
ibiscp wants to merge 1 commit intolivekit:mainfrom
ibiscp:fix/speak-to-ivr
Open

feat(beta/tools): add speak_to_ivr tool auto-injected with ivr_detection#5399
ibiscp wants to merge 1 commit intolivekit:mainfrom
ibiscp:fix/speak-to-ivr

Conversation

@ibiscp
Copy link
Copy Markdown

@ibiscp ibiscp commented Apr 9, 2026

Problem

ivr_detection=True automatically injects send_dtmf_events for key presses, but provides no equivalent for verbal responses. IVR systems use both modalities: pressing digits and saying phrases ("say your name", "say yes or no", "say your account number"). Without a built-in tool, every developer building an IVR agent must implement the same boilerplate:

@function_tool()
async def speak_to_ivr(self, context: RunContext, text: str) -> None:
    handle = self.session.say(text, allow_interruptions=False)
    await context.wait_for_playout()
    await handle
    raise StopResponse()

And then instruct the agent via system prompt to always call it after every verbal response. This is the same class of problem as the missing StopResponse in send_dtmf_events — the tool exists conceptually but the correct behavior isn't encoded by default.

Fix

Add speak_to_ivr as a built-in function_tool in beta/tools/ and auto-inject it alongside send_dtmf_events via IVRActivity.tools. The tool calls session.say() with allow_interruptions=False (appropriate for IVR contexts where the agent must finish speaking before the IVR processes the response), waits for playout, and raises StopResponse() to yield the turn back to the IVR.

send_dtmf_events and speak_to_ivr are symmetric IVR interaction primitives — key presses and verbal responses. Both should be available out of the box when ivr_detection=True.

Impact

  • No breaking changes. speak_to_ivr is additive.
  • Agents using ivr_detection=True will now have speak_to_ivr available automatically. Agents that already define their own equivalent tool should remove it to avoid duplication.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

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