fix: describe local intent answers to the model instead of replaying them
With prefer_local_intents, Home Assistant puts requests its local intents answered into the chat log as external calls of intents like HassGetCurrentTime. The model does not have these tools, and replayed as its own calls they make it apologise for using tools it does not have and doubt answers it never gave. They are now passed as a developer note with the intent, its arguments and its result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e54f0f0fa1
commit
6aed494e44
3 files changed
+77
-1
No files matched your search
@@ -135,3 +135,50 @@ async def test_web_search_location_leaves_out_empty_fields(
|
||||
"country": "DE",
|
||||
"timezone": "Europe/Berlin",
|
||||
}
|
||||
|
||||
|
||||
def test_local_intent_replayed_as_note() -> None:
|
||||
"""Test a request a local intent answered is described, not replayed as a call.
|
||||
|
||||
With prefer_local_intents, the chat log holds intents like
|
||||
HassGetCurrentTime as external tool calls. They are not the model's tools,
|
||||
and replayed as its own calls they make it apologise for using them.
|
||||
"""
|
||||
content = [
|
||||
conversation.UserContent(content="What time is it?"),
|
||||
conversation.AssistantContent(
|
||||
agent_id="conversation.test",
|
||||
tool_calls=[
|
||||
llm.ToolInput(
|
||||
id="intent_1",
|
||||
tool_name="HassGetCurrentTime",
|
||||
tool_args={},
|
||||
external=True,
|
||||
)
|
||||
],
|
||||
),
|
||||
conversation.ToolResultContent(
|
||||
agent_id="conversation.test",
|
||||
tool_call_id="intent_1",
|
||||
tool_name="HassGetCurrentTime",
|
||||
result=llm.ToolResult(data={"speech": {"plain": {"speech": "10:29"}}}),
|
||||
),
|
||||
conversation.AssistantContent(
|
||||
agent_id="conversation.test", content="It is 10:29"
|
||||
),
|
||||
conversation.UserContent(content="What is your name?"),
|
||||
]
|
||||
|
||||
messages = _convert_content_to_param(content)
|
||||
|
||||
assert [message["type"] for message in messages] == ["message"] * 4
|
||||
assert [message["role"] for message in messages] == [
|
||||
"user",
|
||||
"developer",
|
||||
"assistant",
|
||||
"user",
|
||||
]
|
||||
note = messages[1]["content"]
|
||||
assert "HassGetCurrentTime" in note
|
||||
assert "10:29" in note
|
||||
assert "not one of your tools" in note
|
||||
Reference in new issue
Block a user