Skip to content

[Bug]: Third-party Anthropic-compatible providers get Claude Code identity injected #7366

@n-WN

Description

@n-WN

Bug Description

When using third-party Anthropic-compatible providers (Kimi, MiniMax, DashScope, etc.) via api_mode: anthropic_messages, the agent incorrectly self-identifies as "Claude Code" and replaces all mentions of "Hermes Agent" with "Claude Code" in the system prompt.

Root Cause

_is_oauth_token() in agent/anthropic_adapter.py only excludes sk-ant-api* prefixed keys. Any third-party API key (e.g. sk-kimi-*) returns True, causing _is_anthropic_oauth to be set, which triggers:

  1. System prompt prepend: "You are Claude Code, Anthropic's official CLI for Claude."
  2. Text replacement: "Hermes Agent""Claude Code", "Nous Research""Anthropic"
  3. Tool name prefixing with mcp_

Additionally, this code path hits two secondary crashes:

  • AttributeError: 'NoneType' object has no attribute 'get' on self.request_overrides.get("speed") when gateway sets request_overrides = None
  • UnboundLocalError on api_kwargs in the retry-exhaustion error handler

Steps to Reproduce

  1. Configure a Kimi API key (sk-kimi-*) with provider: custom and api_mode: anthropic_messages
  2. Send a message via the gateway (Telegram/Discord/Slack)
  3. Ask the agent "who are you?"
  4. Agent responds as "Claude Code" instead of "Hermes Agent"

Expected Behavior

Third-party providers using the Anthropic Messages API should not get Claude Code identity injection.

Environment

  • Hermes Agent v0.8.0
  • Provider: Kimi (api_mode: anthropic_messages)
  • Platform: Telegram gateway

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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