NousResearch/hermes-agent · error · ValueError
Model {agent.model} has a context window of {_ctx:,} tokens,
Error message
Model {agent.model} has a context window of {_ctx:,} tokens, which is below the minimum {MINIMUM_CONTEXT_LENGTH:,} required by Hermes Agent. Choose a model with at least {MINIMUM_CONTEXT_LENGTH // 1000}K context. If your server reports a window smaller than the model's true window, set model.context_length in config.yaml to the real value (this must be at least {MINIMUM_CONTEXT_LENGTH // 1000}K). What it means
Hermes requires at least MINIMUM_CONTEXT_LENGTH (64K) tokens of context for reliable tool-calling workflows; this ValueError fires at init when context_compressor.context_length is positive but below that floor. One documented escape hatch: provider 'lmstudio' with an explicit positive integer model.context_length in config.yaml is allowed below the floor.
Source
Thrown at agent/agent_init.py:2653
agent.codex_app_server_auto_compaction = codex_app_server_auto_compaction
agent.codex_responses_native_compaction = codex_responses_native_compaction
agent.codex_responses_compact_threshold = codex_responses_compact_threshold
agent.max_compression_attempts = compression_max_attempts
agent.compression_idle_compact_after_seconds = (
compression_idle_compact_after_seconds
)
# Reject models whose context window is below the minimum required
# for reliable tool-calling workflows (64K tokens).
_ctx = getattr(agent.context_compressor, "context_length", 0)
_allow_lmstudio_explicit_below_floor = (
str(getattr(agent, "provider", "") or "").strip().lower() == "lmstudio"
and isinstance(agent._config_context_length, int)
and not isinstance(agent._config_context_length, bool)
and agent._config_context_length > 0
)
if _ctx and _ctx < MINIMUM_CONTEXT_LENGTH and not _allow_lmstudio_explicit_below_floor:
raise ValueError(
f"Model {agent.model} has a context window of {_ctx:,} tokens, "
f"which is below the minimum {MINIMUM_CONTEXT_LENGTH:,} required "
f"by Hermes Agent. Choose a model with at least "
f"{MINIMUM_CONTEXT_LENGTH // 1000}K context. If your server "
f"reports a window smaller than the model's true window, set "
f"model.context_length in config.yaml to the real value "
f"(this must be at least {MINIMUM_CONTEXT_LENGTH // 1000}K)."
)
# Nous Hermes 3/4 are chat models, not tool-call-tuned. The interactive
# CLI already warns via cli.py show_banner() (richer output + /model hint),
# so skip platform=="cli" here to avoid emitting the warning twice per
# startup. (Gateway/TUI/cron construct with quiet_mode=True and are already
# gated off by the `not agent.quiet_mode` check above; this guard's active
# job is the CLI dedup, and it leaves the door open for any non-quiet
# non-CLI surface to still surface the warning.)
if not agent.quiet_mode and (agent.platform or "cli") != "cli":
try:View on GitHub (pinned to c896c09c42)
Solutions
- Switch to a model with at least 64K context via `hermes model`
- If the server under-reports the true window, set model.context_length in config.yaml to the real value — the below-floor override is honored only for provider lmstudio with an explicit positive integer
- Fix the local server's reported context so the resolved value is accurate
- Remove/repair any model.context_length that coerces to 0 or False
Example fix
# config.yaml — before (provider: lmstudio, server reports 8K) model: name: my-local-model # after (explicit override of the server's under-report) model: name: my-local-model context_length: 131072
Defensive patterns
Strategy: validation
Validate before calling
from agent.constants import MINIMUM_CONTEXT_LENGTH # 65536
def context_ok(resolved_context: int, provider: str, config_ctx) -> bool:
if not resolved_context or resolved_context >= MINIMUM_CONTEXT_LENGTH:
return True
return (
provider.strip().lower() == "lmstudio"
and isinstance(config_ctx, int)
and not isinstance(config_ctx, bool)
and config_ctx > 0
)
assert context_ok(resolved_ctx, provider, config_ctx), "model context below 64K floor" Try / catch
try:
agent = AIAgent(...)
except ValueError as e:
if "context window" in str(e) and "below the minimum" in str(e):
suggest_model_with_64k() # or set model.context_length for lmstudio
else:
raise Prevention
- Check the model's advertised context length before selecting it in `hermes model`
- For LM Studio models whose server under-reports, always set model.context_length explicitly
- Avoid legacy sub-64K models for tool-calling workflows
When it happens
Trigger: The provider/model catalog (or server-reported value) resolves a context length < 65536 for the chosen model, and either the provider is not lmstudio, or it is lmstudio but model.context_length is missing, zero, or a bool — so _allow_lmstudio_explicit_below_floor is False.
Common situations: Pointing hermes at a small local model (8K/32K Ollama or LM Studio quant); a server under-reporting the model's true window; a stale catalog entry with a low context length; model.context_length accidentally set to 0.
Related errors
- Invalid profile name: ${value}
- SSH host is required.
- Malformed custom endpoint URL: {candidate!r}. Run `hermes se
- Auxiliary compression model {aux_model} has a context window
- iron-proxy rejected the new config (validation failed; the r
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/9b0d6cc61c16180a.
Report an issue: GitHub.