hermes - 💡(How to fix) Fix get_model_context_length() unconditionally queries OpenRouter metadata even for non-OpenRouter users, causing false "below minimum 64K" rejections

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

ValueError: Model kimi-k2.6 has a context window of 32,768 tokens, which is below the minimum 64,000 required by Hermes Agent.

Root Cause

fetch_model_metadata() unconditionally hits https://openrouter.ai/api/v1/models even when:

  • OPENROUTER_API_KEY is not set
  • The active provider is not OpenRouter
  • The endpoint base_url is not OpenRouter

OpenRouter's data is treated as provider-unaware fallback authority, but it can be stale or wrong for models it doesn't directly host.

Fix Action

Fix / Workaround

Current Workaround

Code Example

ValueError: Model kimi-k2.6 has a context window of 32,768 tokens, which is below the minimum 64,000 required by Hermes Agent.
RAW_BUFFERClick to expand / collapse

get_model_context_length() unconditionally queries OpenRouter metadata even for non-OpenRouter users, causing false "below minimum 64K" rejections

Problem

agent/model_metadata.py::get_model_context_length() calls fetch_model_metadata() (OpenRouter /models API) as step 6 in the resolution chain, regardless of which provider the user actually configured.

This means users on Kimi Coding, Moonshot, Ollama Cloud, or any other non-OpenRouter provider can receive incorrect context_length values from OpenRouter's stale metadata — specifically, OpenRouter reports 32768 for moonshotai/kimi-k2.6 when the model actually supports 262144.

The 64K minimum-context guard in run_agent.py then rejects the model with:

ValueError: Model kimi-k2.6 has a context window of 32,768 tokens, which is below the minimum 64,000 required by Hermes Agent.

Impact

  • Cron jobs fail silently (logged but not surfaced to user)
  • Gateway DM sessions fail to initialize agent
  • Any code path that constructs AIAgent without explicit config_context_length override is affected

Reproduction

  1. Configure Hermes with provider: kimi-coding, model: kimi-k2.6, no model.context_length override
  2. Run any cron job or gateway session
  3. AIAgent.__init__ContextCompressor.__init__get_model_context_length()fetch_model_metadata() returns 32768 from OpenRouter cache → ValueError

Root Cause

fetch_model_metadata() unconditionally hits https://openrouter.ai/api/v1/models even when:

  • OPENROUTER_API_KEY is not set
  • The active provider is not OpenRouter
  • The endpoint base_url is not OpenRouter

OpenRouter's data is treated as provider-unaware fallback authority, but it can be stale or wrong for models it doesn't directly host.

Current Workaround

Commit 91eef6255 added a narrow guard: reject exactly 32768 for Kimi-family models from OpenRouter metadata and fall through to hardcoded defaults. This fixes the symptom for kimi-k2.6 but leaves the architecture issue intact.

Suggested Fix

  1. Skip OpenRouter fallback when OpenRouter is not configured — if OPENROUTER_API_KEY is absent and the active provider is known non-OpenRouter, don't query OpenRouter metadata.
  2. Or: Move OpenRouter fallback to the absolute end of the chain (step 9), after hardcoded defaults and local queries.
  3. Or: Add a model.context_length auto-population during hermes setup so users don't silently depend on runtime probing.

Environment

  • Hermes version: post-91eef6255
  • Provider: kimi-coding
  • Model: kimi-k2.6
  • macOS 26.4.1

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING