Skip to content

Custom Kimi-compatible endpoint with api_mode=anthropic_messages fails after tool call when thinking is enabled #17057

@imkenf

Description

@imkenf

Title

custom Kimi-compatible endpoint with api_mode=anthropic_messages fails after tool call when thinking is enabled

Summary

When Hermes is configured with:

model:
  default: kimi-2.6
  provider: custom
  base_url: http://<custom-endpoint>
  api_mode: anthropic_messages

agent:
  reasoning_effort: medium

the next request after a tool call can fail with:

HTTP 400: thinking is enabled but reasoning_content is missing in assistant tool call message at index 2

Reproduction

  1. Use a custom Kimi-compatible endpoint with api_mode: anthropic_messages.
  2. Enable reasoning, for example agent.reasoning_effort: medium.
  3. Trigger any tool call.
  4. Let Hermes continue to the next model request.

Observed behavior

Hermes sends Anthropic-style thinking, but prior assistant tool-call history does not include reasoning_content, so the upstream endpoint rejects the request.

Example request shape:

{
  "messages": [
    { "role": "user", "content": "..." },
    {
      "role": "assistant",
      "content": [
        { "type": "tool_use", "name": "skill_view", "id": "..." }
      ]
    },
    {
      "role": "user",
      "content": [
        { "type": "tool_result", "tool_use_id": "...", "content": "..." }
      ]
    }
  ],
  "thinking": { "type": "enabled", "budget_tokens": 8000 }
}

Relevant code

There is already a regression test for this failure mode on official Kimi endpoints:

  • tests/agent/test_kimi_coding_anthropic_thinking.py

And the current special-case appears to be URL-specific in:

  • agent/anthropic_adapter.py

Problem

The current guard seems to only match official Kimi URLs such as https://api.kimi.com/coding....

It does not cover custom or proxied Kimi-compatible endpoints, even when they have the same behavior and reject Anthropic thinking unless assistant tool-call history includes reasoning_content.

Expected behavior

Hermes should suppress Anthropic thinking for Kimi-compatible custom endpoints as well, not only for the official Kimi URL pattern.

Suggested fix

Broaden the current Kimi special-case beyond strict URL matching. For example:

  • detect Kimi-compatible custom endpoints by model family plus api_mode=anthropic_messages
  • or use capability-based detection instead of hostname-only detection

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt builderprovider/kimiKimi / Moonshottype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions