From c64b1ae111ad02b29ee297349c8d55f38e8f0263 Mon Sep 17 00:00:00 2001 From: suixinio Date: Mon, 18 Aug 2025 23:50:01 +0800 Subject: [PATCH] fix(openrouter): Force string serialization for openrouter/anthropic/claude-sonnet-4 model (#10454) --- openhands/llm/llm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openhands/llm/llm.py b/openhands/llm/llm.py index 997f82fecb..3d76116af9 100644 --- a/openhands/llm/llm.py +++ b/openhands/llm/llm.py @@ -850,6 +850,8 @@ class LLM(RetryMixin, DebugMixin): message.force_string_serializer = True if 'kimi-k2-instruct' in self.config.model and 'groq' in self.config.model: message.force_string_serializer = True + if 'openrouter/anthropic/claude-sonnet-4' in self.config.model: + message.force_string_serializer = True # let pydantic handle the serialization return [message.model_dump() for message in messages]