Skip to content

fix(config): respect model.context_length override for sub-64K models#9142

Open
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/context-length-config-override
Open

fix(config): respect model.context_length override for sub-64K models#9142
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/context-length-config-override

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

When the user explicitly sets model.context_length in config.yaml, the minimum 64K context check is now bypassed. Previously the check rejected models below 64K even when the user had already configured the override that the error message itself recommended.

Why: Users of smaller models (e.g. Qwen3-235B-A22B with 32K context) were blocked from using Hermes Agent even after following the error message's instructions to set model.context_length in config.

How:

  • Extracted validate_minimum_context() function from AIAgent.__init__ so the validation logic is testable
  • Added config_context_length is None guard so explicit overrides bypass the check
  • 5 regression tests covering: reject without override, accept with override, boundary conditions, zero context

Related Issue

Closes #8430

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Extracted validate_minimum_context() function from AIAgent.__init__ so the validation logic is testable
  • Added config_context_length is None guard so explicit overrides bypass the check
  • tests/run_agent/test_minimum_context_length.py — 5 regression tests (reject without override, accept with override, boundary conditions, zero context)

How to Test

  1. pytest tests/run_agent/test_minimum_context_length.py -v — 5 tests pass
  2. pytest tests/run_agent/test_switch_model_context.py -v — related tests pass (no regression)

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15 (Darwin 24.6.0)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

$ pytest tests/run_agent/test_minimum_context_length.py -v
5 tests pass

@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 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Multiple PRs for the same fix: #11097, #8962, #8590 (closed). Consider consolidating — this is the oldest open PR for the issue.

@viztastic

Copy link
Copy Markdown

Any support required to merge this PR in? it'll open hermes up to a huge section of the community who run local models.

@viztastic viztastic left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

When users explicitly set model.context_length in config.yaml, the
minimum 64K context check is now bypassed. Previously the check rejected
models below 64K even when the user had already configured the override
that the error message itself recommended.

Closes NousResearch#8430
@Tranquil-Flow Tranquil-Flow force-pushed the fix/context-length-config-override branch from 06c0b81 to 1efa93e Compare May 25, 2026 11:07
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

3 participants