fix(agent): respect model.context_length config - #37548
Conversation
Hermes CI triageCI is currently failing for this PR in two places:
if _config_context_length is not None and _ctx and _ctx < _config_context_length:
...
if _config_context_length is None and _ctx and _ctx < MINIMUM_CONTEXT_LENGTH:
...Also small style nit: Evidence: failing jobs |
|
The split logic removes the Original code (line 1476 on main): _ctx = getattr(agent.context_compressor, "context_length", 0)
if _ctx and _ctx < MINIMUM_CONTEXT_LENGTH:The PR code: if(_config_context_length is not None and _ctx < _config_context_length):When Suggested fix — restore the if _ctx and _config_context_length is not None and _ctx < _config_context_length:
raise ValueError(...)
if _ctx and _config_context_length is None and _ctx < MINIMUM_CONTEXT_LENGTH:
raise ValueError(...)This preserves the original "skip when unknown" behavior while adding the user-configured override path. A test for the |
|
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.
What does this PR do?
This PR fixes #8430 in a exhaustive way, introducing proper context length checking in case the user has provided a model.context_length config.
Related Issue
#8430
Fixes #8430
Type of Change
Changes Made
How to Test
model.context_lengthin config to be less than 64000Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A