diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.py index e3f23059d8..3612ce1a64 100644 --- a/agent/anthropic_adapter.py +++ b/agent/anthropic_adapter.py @@ -1083,6 +1083,13 @@ def convert_messages_to_anthropic( "name": fn.get("name", ""), "input": parsed_args, }) + # Kimi's /coding endpoint (Anthropic protocol) requires assistant + # tool-call messages to carry reasoning_content when thinking is + # enabled. Preserve it as a thinking block so Kimi can validate + # the message history. See hermes-agent#13848. + reasoning_content = m.get("reasoning_content") + if reasoning_content and isinstance(reasoning_content, str): + blocks.append({"type": "thinking", "thinking": reasoning_content}) # Anthropic rejects empty assistant content effective = blocks or content if not effective or effective == "":