The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(providers): lazy header resolution lock is re-entrant
Teknium5e772277c77f
diff --git a/providers/base.py b/providers/base.pyindex c7c55b9a3cb..90f9f8e15a9 100644--- a/providers/base.py+++ b/providers/base.py@@ -39,7 +39,7 @@ def _profile_user_agent() -> str:return "hermes-cli"-_RESOLVE_LOCK = threading.Lock()+_RESOLVE_LOCK = threading.RLock() # re-entrant: a callback may read another LazyHeadersclass LazyHeaders(dict[str, str]):diff --git a/tests/hermes_cli/test_version_info_startup_git.py b/tests/hermes_cli/test_version_info_startup_git.pyindex b46e7e9e819..73c32968f01 100644--- a/tests/hermes_cli/test_version_info_startup_git.py+++ b/tests/hermes_cli/test_version_info_startup_git.py@@ -78,6 +78,12 @@ def test_provider_headers_run_no_git_until_read_and_stay_a_dict_for_overrides(tm"headers = {'X-Tier': 'pro'} | (base.default_headers | headers)\n""register_provider(dataclasses.replace(base, name='gmi-acct', aliases=(), default_headers=headers))\n"),+ # A lazy header derived from another profile's unread lazy header (nested resolution).+ "gmi-tag": (+ "from providers.base import LazyHeaders\n"+ "headers = LazyHeaders({'User-Agent': lambda: base.default_headers['User-Agent'] + ' eu'})\n"+ "register_provider(dataclasses.replace(base, name='gmi-tag', aliases=(), default_headers=headers))\n"+ ),}code = ("import json, os, pathlib, hermes_cli.config, providers\n"@@ -93,7 +99,7 @@ def test_provider_headers_run_no_git_until_read_and_stay_a_dict_for_overrides(tm" \"base = get_provider_profile('gmi')\\n\" + body)\n""providers._home_layer(force_stamp_check=True)\n""from hermes_cli.version_info import get_version_info\n"- "found = {n: providers.get_provider_profile(n) for n in ('gmi-eu', 'gmi-acct')}\n"+ "found = {n: providers.get_provider_profile(n) for n in ('gmi-eu', 'gmi-acct', 'gmi-tag')}\n""print(json.dumps({'before': before, 'ua': ua, 'base': get_version_info().base_version,\n"" 'found': {n: p and dict(p.default_headers) for n, p in found.items()}}))\n")@@ -106,6 +112,7 @@ def test_provider_headers_run_no_git_until_read_and_stay_a_dict_for_overrides(tmassert result["found"] == {"gmi-eu": {"User-Agent": ua},"gmi-acct": {"X-Tier": "pro", "User-Agent": ua, "X-Account": "eu"},+ "gmi-tag": {"User-Agent": f"{ua} eu"},}