fix(run_agent): honor model.context_length override for sub-64K models - #11097
fix(run_agent): honor model.context_length override for sub-64K models#11097c0nSpIc0uS7uRk3r wants to merge 1 commit into
Conversation
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.
|
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 |
|
Thanks for the PR. Closing — this is working as intended, not a bug. The 64K context-window floor is deliberate: Hermes' tool schemas + system prompt consume a large fixed prefix, and sub-64K windows aren't reliable for agentic tool-calling. We don't want anyone running below 64K, so there is intentionally no escape hatch to override the floor with a smaller value. The real defect here was the error message — it advertised "or set Note: Appreciate the clean, minimal diff — the reasoning just points the other way on this one. |
…age (#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (#11097, #11110, #8962, #9142, #37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
…age (NousResearch#53569) The error raised when a model's context window is below the 64K minimum advertised "or set model.context_length in config.yaml to override" — but the guard intentionally has no sub-64K escape hatch. Sub-64K models are rejected by design (tool schemas + system prompt need the headroom). The misleading clause invited a cluster of dup PRs (NousResearch#11097, NousResearch#11110, NousResearch#8962, NousResearch#9142, NousResearch#37548) all trying to wire an override that we don't want. Reword to state the real options: pick a >=64K model, or — if your local server under-reports its true window — declare the real value (which must itself be >=64K). Guard behavior is unchanged.
Summary
Commit c8aff74 ("prevent agent from stopping mid-task") added a
MINIMUM_CONTEXT_LENGTH=64Kguard inAIAgent.__init__that rejects agent initialization for any model whose native context window is smaller than 64K. The raisedValueErrorexplicitly documents an escape hatch:But the guard fires unconditionally — it never checks whether the operator actually set
model.context_lengthinconfig.yaml. The promised escape hatch is cosmetic.Fix
Add
and _config_context_length is Noneto the gate condition._config_context_lengthis already a local variable in the same__init__method, populated from the config.yaml value, so no additional plumbing is needed.Behavior change
model.context_length): unchanged — guard still fires, agent still refuses to start against sub-64K models.model.context_lengthin config.yaml, accepting sub-64K risk): agent now starts, matching what the error message already promises.Repro
config.yaml:hermes chat -q "hello" -Qagainst a model with a 32K native context (e.g. Qwen 3.5 35B-A3B).ValueError: Model ... has a context window of 32,000 tokens, which is below the minimum 65,536...Related
Addresses Bug 1 from #11096 (combined issue covering three v0.9.0 rough edges).