mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-22 16:25:58 +00:00
fix(context): preserve missing-key compression history
This commit is contained in:
parent
202ad1b8c9
commit
577beeb9b9
8 changed files with 251 additions and 17 deletions
|
|
@ -854,11 +854,19 @@ class TestAuthFailureAborts:
|
|||
def test_quota_classifier_accepts_explicit_provider_signals(self, message):
|
||||
assert _is_summary_access_or_quota_error(Exception(message)) is True
|
||||
|
||||
def test_missing_provider_api_key_is_terminal_access_failure(self):
|
||||
err = RuntimeError(
|
||||
"Provider 'opencode-zen' is set in config.yaml but no API key was "
|
||||
"found. Set the OPENCODE-ZEN_API_KEY environment variable."
|
||||
)
|
||||
assert _is_summary_access_or_quota_error(err) is True
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"message",
|
||||
[
|
||||
"billing portal is temporarily unavailable",
|
||||
"usage limit documentation could not be loaded",
|
||||
"API key documentation was not found",
|
||||
"rate limit exceeded; retry later",
|
||||
"quota exceeded, please retry after the window resets",
|
||||
"request timed out",
|
||||
|
|
@ -905,6 +913,34 @@ class TestAuthFailureAborts:
|
|||
assert c._last_compress_aborted is True
|
||||
assert c._last_summary_fallback_used is False
|
||||
|
||||
def test_missing_provider_api_key_preserves_original_messages(self):
|
||||
"""A configured auxiliary provider without a visible key preserves context."""
|
||||
err = RuntimeError(
|
||||
"Provider 'opencode-zen' is set in config.yaml but no API key was "
|
||||
"found. Set the OPENCODE-ZEN_API_KEY environment variable, or switch "
|
||||
"to a different provider with hermes model."
|
||||
)
|
||||
with patch(
|
||||
"agent.context_compressor.get_model_context_length", return_value=100000
|
||||
):
|
||||
c = ContextCompressor(
|
||||
model="test",
|
||||
quiet_mode=True,
|
||||
protect_first_n=2,
|
||||
protect_last_n=2,
|
||||
abort_on_summary_failure=False,
|
||||
)
|
||||
msgs = self._msgs(12)
|
||||
with patch("agent.context_compressor.call_llm", side_effect=err):
|
||||
result = c.compress(msgs, current_tokens=999999, force=True)
|
||||
|
||||
assert result == msgs
|
||||
assert c._last_summary_error == str(err)
|
||||
assert c._last_summary_auth_failure is True
|
||||
assert c._last_compress_aborted is True
|
||||
assert c._last_summary_fallback_used is False
|
||||
assert c._last_summary_dropped_count == 0
|
||||
|
||||
def test_402_quota_with_retry_uses_existing_fallback(self):
|
||||
"""A reset-window quota remains transient instead of aborting compression."""
|
||||
err = StubProviderError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue