Add tool/function call support to webhook conversation responses - #35
Conversation
- Parse tool_calls from webhook responses (both streaming and non-streaming) - Add tool execution loop (up to MAX_TOOL_ITERATIONS) in conversation handler - Include tool call info (tool_calls, tool_call_id, tool_name) in messages sent to webhook - Update models with WebhookConversationToolCall type and optional fields - Update AI task entity to handle new _send_payload return type Co-authored-by: EuleMitKeule <47421406+EuleMitKeule@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds webhook tool/function-call round-trip support to the conversation integration so external webhook backends can return structured tool calls, receive tool results back in subsequent requests, and more closely match Home Assistant’s native LLM tool-calling flow.
Changes:
- Added tool-call models and extended webhook message serialization to include assistant tool calls plus tool result metadata.
- Updated conversation handling to parse webhook
tool_calls, loop over tool execution rounds, and support streamedtool_callschunks. - Adjusted shared webhook send helpers and AI task handling for the new non-streaming/streaming response shapes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
custom_components/webhook_conversation/models.py |
Adds TypedDicts/fields for tool calls and tool-result metadata in webhook messages. |
custom_components/webhook_conversation/entity.py |
Changes webhook send helpers to return full response objects and serializes tool calls/tool results into outbound payloads. |
custom_components/webhook_conversation/conversation.py |
Implements multi-iteration tool execution flow and streamed/non-streamed tool-call parsing for conversations. |
custom_components/webhook_conversation/ai_task.py |
Adapts AI task response handling to the updated webhook helper return types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot fix all the review comments and the mypy issues |
…eration error, follow-up payload fields, mypy type annotation Agent-Logs-Url: https://github.com/EuleMitKeule/webhook-conversation/sessions/7f6402e2-836c-4e52-841f-9e7505940d4d Co-authored-by: EuleMitKeule <47421406+EuleMitKeule@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot resolve the merge conflicts and review comments |
… acceptance to conversation entity Agent-Logs-Url: https://github.com/EuleMitKeule/webhook-conversation/sessions/a501f3d3-f7a4-41b9-83e4-456de77d65fe Co-authored-by: EuleMitKeule <47421406+EuleMitKeule@users.noreply.github.com>
Resolved in ba9d225:
|
|
@copilot resolve the merge conflicts in this pull request, check ruff and mypy |
…nflict and mypy Co-authored-by: EuleMitKeule <47421406+EuleMitKeule@users.noreply.github.com>
…r_name in follow-up payloads Agent-Logs-Url: https://github.com/EuleMitKeule/webhook-conversation/sessions/d03bf29a-ee84-448b-99fa-795654baed41 Co-authored-by: EuleMitKeule <47421406+EuleMitKeule@users.noreply.github.com>
Resolved in fa83ba3:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🎉 This PR is included in version 1.12.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
is not Nonecheck (entity.py:198)_send_payloadto accept responses with onlytool_callsand no text field (entity.py:123-124)HomeAssistantErrorwhenMAX_TOOL_ITERATIONSexceeded (conversation.py:141-161)device_infoandexposed_entitieson follow-up tool iteration payloads (conversation.py:164-169)replyasAnyin ai_task.pyOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.