fix: make the home location lookup work against Claude
validate / hassfest (push) Failing after 11s
validate / hacs (push) Failing after 23s
test / pytest (push) Successful in 46s

- Send the location question as a user message. A request with only a
  system message has no user content, which endpoints in front of Anthropic
  models reject ("text content blocks must be non-empty").
- Leave unknown fields out of the web search user_location. After a failed
  lookup there is no city or region, and the empty strings made every
  request fail ("user_location.city: String should have at least 1
  character").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pc-heiniandClaude Opus 5.5 committed 2026-10-22 08:52:14 +02:00
1 parent 235c536cab
commit 84f4bcda55
4 files changed
+63 -7

No files matched your search

@@ -708,9 +708,11 @@ class OpenAISubentryFlowHandler(ConfigSubentryFlow):
try:
response = await client.responses.create(
model=self.options.get(CONF_CHAT_MODEL, RECOMMENDED_CHAT_MODEL),
# A user message, not a system one: endpoints in front of
# Anthropic models reject a request without user content.
input=[
{
"role": "system",
"role": "user",
"content": "Where are the following coordinates located: "
f"({zone_home.attributes[EntityStateAttribute.LATITUDE]},"
f" {zone_home.attributes[EntityStateAttribute.LONGITUDE]})?",