From 646fd953afc253ba8bbfbe1ad5ab9d822722defb Mon Sep 17 00:00:00 2001 From: Robot Date: Thu, 26 Feb 2026 17:51:29 +0000 Subject: [PATCH] fix: omit container param when None to avoid proxy 400 errors --- custom_components/anthropic_custom/entity.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/anthropic_custom/entity.py b/custom_components/anthropic_custom/entity.py index bb6abc2..87519c4 100644 --- a/custom_components/anthropic_custom/entity.py +++ b/custom_components/anthropic_custom/entity.py @@ -687,7 +687,7 @@ class AnthropicBaseLLMEntity(Entity): max_tokens=options.get(CONF_MAX_TOKENS, DEFAULT[CONF_MAX_TOKENS]), system=system_prompt, stream=True, - container=container_id, + **({"container": container_id} if container_id else {}), ) if not model.startswith(tuple(NON_ADAPTIVE_THINKING_MODELS)): @@ -849,7 +849,7 @@ class AnthropicBaseLLMEntity(Entity): try: stream = await client.messages.create(**model_args) - new_messages, model_args["container"] = _convert_content( + new_messages, _new_container = _convert_content( [ content async for content in chat_log.async_add_delta_content_stream( @@ -862,6 +862,8 @@ class AnthropicBaseLLMEntity(Entity): ) ] ) + if _new_container: + model_args["container"] = _new_container messages.extend(new_messages) except anthropic.AnthropicError as err: raise HomeAssistantError(