mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(gateway): also tolerate malformed env vars in custom human-delay mode
Widens @Krionex's PR #16933 fix to cover the second bug class at the sibling site. natural mode used to pass env values through int() before the PR caught mis-typed values crashing the gateway; custom mode had the exact same bug one branch away (HERMES_HUMAN_DELAY_MIN_MS=oops in custom mode still crashed). Same try/except/fallback pattern, scoped to the two int() calls that feed random.uniform().
This commit is contained in:
parent
3b16c590e0
commit
285c208cf7
2 changed files with 20 additions and 2 deletions
|
|
@ -512,6 +512,17 @@ class TestGetHumanDelay:
|
|||
delay = BasePlatformAdapter._get_human_delay()
|
||||
assert 0.1 <= delay <= 0.2
|
||||
|
||||
def test_custom_mode_tolerates_malformed_env_vars(self):
|
||||
env = {
|
||||
"HERMES_HUMAN_DELAY_MODE": "custom",
|
||||
"HERMES_HUMAN_DELAY_MIN_MS": "oops",
|
||||
"HERMES_HUMAN_DELAY_MAX_MS": "still-bad",
|
||||
}
|
||||
with patch.dict(os.environ, env):
|
||||
# falls back to the custom-mode defaults instead of crashing
|
||||
delay = BasePlatformAdapter._get_human_delay()
|
||||
assert 0.8 <= delay <= 2.5
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# utf16_len / _prefix_within_utf16_limit / truncate_message with len_fn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue