Skip to content

bug(gateway): AttributeError 'NoneType' object has no attribute 'get' on Anthropic adapter via Mattermost gateway #7346

@nericervin

Description

@nericervin

Description

After updating to the latest main (commit 7e60b092), all Mattermost gateway bots fail with:

⚠️  API call failed (attempt 1/3): AttributeError
   🔌 Provider: anthropic  Model: claude-sonnet-4-6
   🌐 Endpoint: https://api.anthropic.com
   📝 Error: 'NoneType' object has no attribute 'get'
   ⏱️  Elapsed: 0.00s  Context: 4 msgs, ~9,865 tokens

The error occurs before the HTTP request is sent (Elapsed: 0.00s), suggesting it happens during request construction in the Anthropic adapter or prompt builder.

Environment

  • Platform: Mattermost gateway (Docker)
  • Provider: Anthropic (direct, ANTHROPIC_API_KEY)
  • Models: claude-sonnet-4-6, claude-opus-4-6
  • Previous working version: v0.8.0 (commit 86960cdb)
  • Broken since: latest main (7e60b092)

Reproduction

  1. Configure Hermes with Mattermost gateway
  2. Set model.default: claude-sonnet-4-6 and model.provider: anthropic
  3. Send any message to the bot via Mattermost
  4. Bot fails with the AttributeError above, falls back to fallback model

What works

  • Direct Anthropic API calls from the same container (using anthropic.Anthropic().messages.create()) work fine
  • _resolve_runtime_agent_kwargs() correctly resolves provider: anthropic, base_url: https://api.anthropic.com, api_mode: anthropic_messages
  • Creating an AIAgent manually with those resolved kwargs and calling run_conversation() works
  • The issue only appears when the Mattermost gateway creates the agent

What doesn't work

  • Any message via Mattermost gateway → AttributeError before API call
  • Tested with completely clean state.db (0 messages) — same error
  • Tested with only 4 messages in context — same error
  • All 4 bots (Kellu/Sonnet, Werken/Sonnet, Nometun/Opus, Dewun/Opus) affected

Workaround

Rolled back to pre-update commit (260dfec1, based on v0.8.0) which works correctly.

Config

model:
  default: "claude-sonnet-4-6"
  provider: "anthropic"

fallback_model:
  provider: openrouter
  model: meta-llama/llama-4-maverick

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/gatewayGateway runner, session dispatch, deliveryprovider/anthropicAnthropic native Messages APItype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions