Handle agent_tool_request event type in MessageHandler#15
Open
seahyc wants to merge 2 commits intoelevenlabs:mainfrom
Open
Handle agent_tool_request event type in MessageHandler#15seahyc wants to merge 2 commits intoelevenlabs:mainfrom
agent_tool_request event type in MessageHandler#15seahyc wants to merge 2 commits intoelevenlabs:mainfrom
Conversation
e5f1120 to
43600ac
Compare
When the ElevenLabs agent calls a server-side tool (webhook), the SDK receives an `agent_tool_request` event. Previously this hit the default branch, logging "Unknown event type: agent_tool_request". This adds proper handling mirroring the existing `agent_tool_response` pattern: - `AgentToolRequest` event model with tool_name, tool_call_id, tool_type, and event_id (matching the AsyncAPI schema in elevenlabs/packages) - `onAgentToolRequest` callback in `ConversationCallbacks` - Handler in `MessageHandler` to parse and dispatch the event This allows SDK consumers to react to pending tool calls, e.g. showing a loading indicator while a webhook executes.
43600ac to
dafa5aa
Compare
Add test coverage for MessageHandler event parsing and dispatch, including AgentToolRequest, AgentToolResponse, InterruptionEvent, ClientToolCall model parsing, ping/pong handling, debug callback routing, and unknown event type logging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
Thanks for your contribution 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the ElevenLabs agent calls a server-side tool (webhook), the SDK receives an
agent_tool_requestevent over the data channel. This event type was not handled inMessageHandler, causing it to fall through to the default branch and logUnknown event type: agent_tool_request.This PR adds proper handling that mirrors the existing
agent_tool_responsepattern:AgentToolRequestevent model inevents.dart- parsestool_name,tool_call_id,tool_type, andevent_idfrom the nestedagent_tool_requestpayload (verified against the AsyncAPI schema)onAgentToolRequestcallback inConversationCallbacks- lets SDK consumers react to pending tool calls (e.g., show a loading indicator while a webhook executes)MessageHandler- parses the event and dispatches to the callbackMessageHandlerevent dispatch - coversagent_tool_request,agent_tool_response,end_calltrigger, ping/pong, debug routing, unknown event logging, and event model JSON parsingTest plan
flutter test- all 54 tests pass (10 new tests intest/message_handler_test.dart)agent_tool_requestevents no longer log as unknownonAgentToolRequestcallback fires with correctAgentToolRequestdataagent_tool_responsehandling