Skip to content

fix(examples): raise ToolError instead of returning it in realtime_joke_teller#5904

Merged
u9g merged 1 commit into
mainfrom
fix/realtime-joke-teller-tool-error
May 30, 2026
Merged

fix(examples): raise ToolError instead of returning it in realtime_joke_teller#5904
u9g merged 1 commit into
mainfrom
fix/realtime-joke-teller-tool-error

Conversation

@u9g
Copy link
Copy Markdown
Contributor

@u9g u9g commented May 30, 2026

Summary

  • get_weather, search_web, and tell_joke in examples/voice_agents/realtime_joke_teller.py constructed ToolError(...) and returned it on exception. ToolError is an Exception subclass and the framework's contract is to raise it so the message is surfaced to the LLM — returning serializes it as an opaque success value, and the LLM never learns the call failed.
  • Switched all three sites to raise ToolError(...) from e and dropped the bogus | ToolError return annotations on get_weather and tell_joke.

Every other example in examples/ already uses raise ToolError(...) (drive-thru, frontdesk, healthcare, warm-transfer, web_search, telephony) — this file was the only outlier.

Test plan

  • Run python examples/voice_agents/realtime_joke_teller.py console and trigger an error path (e.g. unreachable joke API / invalid city) — confirm the LLM responds to the failure instead of speaking a serialized object.

…ke_teller

The framework's function-tool error contract is to raise ToolError so the
error message is surfaced to the LLM. Returning the instance serializes it
as an opaque value on the success path, so the LLM never learns the call
failed. Also drop the bogus `| ToolError` return annotations.
@chenghao-mou chenghao-mou requested a review from a team May 30, 2026 18:16
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 1 additional finding.

Open in Devin Review

@u9g u9g merged commit 2de09f9 into main May 30, 2026
27 checks passed
@u9g u9g deleted the fix/realtime-joke-teller-tool-error branch May 30, 2026 18:53
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.

3 participants