mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
Merge pull request #21012 from stephenschoettler/fix/ci-pr-check-unblock
fix(ci): unblock shared PR checks
This commit is contained in:
commit
cd64bed55e
10 changed files with 194 additions and 70 deletions
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests that switch_model preserves config_context_length."""
|
||||
"""Tests that switch_model does not inherit stale context_length overrides."""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ def _make_agent_with_compressor(config_context_length=None) -> AIAgent:
|
|||
agent.client = MagicMock()
|
||||
agent.quiet_mode = True
|
||||
|
||||
# Store config_context_length for later use in switch_model
|
||||
# Store the initial config_context_length override used at agent construction.
|
||||
agent._config_context_length = config_context_length
|
||||
|
||||
# Context compressor with primary model values
|
||||
|
|
@ -41,8 +41,8 @@ def _make_agent_with_compressor(config_context_length=None) -> AIAgent:
|
|||
|
||||
|
||||
@patch("agent.model_metadata.get_model_context_length", return_value=131_072)
|
||||
def test_switch_model_preserves_config_context_length(mock_ctx_len):
|
||||
"""When switching models, config_context_length should be passed to get_model_context_length."""
|
||||
def test_switch_model_clears_previous_config_context_length(mock_ctx_len):
|
||||
"""Switching models must not reuse the previous model.context_length override."""
|
||||
agent = _make_agent_with_compressor(config_context_length=32_768)
|
||||
|
||||
assert agent.context_compressor.model == "primary-model"
|
||||
|
|
@ -51,13 +51,14 @@ def test_switch_model_preserves_config_context_length(mock_ctx_len):
|
|||
# Switch model
|
||||
agent.switch_model("new-model", "openrouter", api_key="sk-new", base_url="https://openrouter.ai/api/v1")
|
||||
|
||||
# Verify get_model_context_length was called with config_context_length
|
||||
# Verify the old config override is not passed to the new model.
|
||||
mock_ctx_len.assert_called_once()
|
||||
call_kwargs = mock_ctx_len.call_args.kwargs
|
||||
assert call_kwargs.get("config_context_length") == 32_768
|
||||
assert call_kwargs.get("config_context_length") is None
|
||||
|
||||
# Verify compressor was updated
|
||||
# Verify compressor was updated from the newly resolved model metadata.
|
||||
assert agent.context_compressor.model == "new-model"
|
||||
assert agent.context_compressor.context_length == 131_072
|
||||
|
||||
|
||||
def test_switch_model_without_config_context_length():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue