Skip to content

fix(run_agent): honor model.context_length override for sub-64K models#11097

Open
c0nSpIc0uS7uRk3r wants to merge 1 commit into
NousResearch:mainfrom
c0nSpIc0uS7uRk3r:pr/fix-context-length-override
Open

fix(run_agent): honor model.context_length override for sub-64K models#11097
c0nSpIc0uS7uRk3r wants to merge 1 commit into
NousResearch:mainfrom
c0nSpIc0uS7uRk3r:pr/fix-context-length-override

Conversation

@c0nSpIc0uS7uRk3r

Copy link
Copy Markdown

Summary

Commit c8aff74 ("prevent agent from stopping mid-task") added a MINIMUM_CONTEXT_LENGTH=64K guard in AIAgent.__init__ that rejects agent initialization for any model whose native context window is smaller than 64K. The raised ValueError explicitly documents an escape hatch:

"or set model.context_length in config.yaml to override"

But the guard fires unconditionally — it never checks whether the operator actually set model.context_length in config.yaml. The promised escape hatch is cosmetic.

Fix

Add and _config_context_length is None to the gate condition. _config_context_length is already a local variable in the same __init__ method, populated from the config.yaml value, so no additional plumbing is needed.

Behavior change

  • Default (operator has not set model.context_length): unchanged — guard still fires, agent still refuses to start against sub-64K models.
  • Override (operator explicitly sets model.context_length in config.yaml, accepting sub-64K risk): agent now starts, matching what the error message already promises.

Repro

  1. In config.yaml:
    model:
      context_length: 32000
  2. Run hermes chat -q "hello" -Q against a model with a 32K native context (e.g. Qwen 3.5 35B-A3B).
  3. Before: ValueError: Model ... has a context window of 32,000 tokens, which is below the minimum 65,536...
  4. After: Agent starts normally, runs to completion.

Related

Addresses Bug 1 from #11096 (combined issue covering three v0.9.0 rough edges).

Commit c8aff74 ("prevent agent from stopping mid-task") added a
MINIMUM_CONTEXT_LENGTH=64K guard that rejects agent init for any model
whose native context window is smaller. The ValueError it raises
documents an escape hatch:

    "or set model.context_length in config.yaml to override"

But the guard fires unconditionally — it never checks whether the
operator set `model.context_length` in config.yaml. The promised
escape hatch is cosmetic.

Fix: add `and _config_context_length is None` to the gate condition.
`_config_context_length` is already a local variable in the same
`__init__` method, populated from the config.yaml value.

Effect: operators running against models with sub-64K native context
(e.g. Qwen 3.5 35B-A3B at 32K) can now explicitly opt in to the
smaller window via `model.context_length: 32000` in config.yaml,
matching the behavior the existing error message already promises.
Default behavior for operators who don't set the override is unchanged.

Repro:
  1. In config.yaml: `model.context_length: 32000`
  2. Run `hermes chat -q "hello" -Q` against a 32K model
  3. Before: ValueError at init. After: runs normally.
@vivganes

Copy link
Copy Markdown
Contributor

This is an important fix. Can we get this out in the next release? my hermes is bricked until then since i run a local model with less context window. The error message asks to set model.context_length but that does not work at all. This fixes it.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder area/config Config system, migrations, profiles labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #8962 — same fix: honor model.context_length config override below 64K minimum. Also related to #9142 (same fix, different PR). Addresses Bug 1 from #11096.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants