fix(bench): remove hardcoded credential paths from benchmark runners (#177)

The `_load_api_key()` function in longmemeval_bench.py and locomo_bench.py
searched for API keys in a fixed path (`~/.config/lu/keys.json`) using
personal key names (`anthropic_milla`, `anthropic_claude_code_main`).

This leaks internal infrastructure details into the public codebase and
trains contributors to store credentials in a non-standard location
rather than using the standard ANTHROPIC_API_KEY env var.

Simplified to: CLI flag > env var > empty string. Updated help text
and HYBRID_MODE.md docs to match.

Co-authored-by: Tadao <tadao@travisfixes.com>
This commit is contained in:
travisBREAKS
2026-04-12 01:14:36 -05:00
committed by GitHub
parent dc143471bc
commit 89206107fa
3 changed files with 4 additions and 44 deletions
+1 -18
View File
@@ -580,29 +580,12 @@ def llm_rerank_locomo(
def _load_api_key(key_arg):
"""Load API key from --llm-key arg or ANTHROPIC_API_KEY env var."""
if key_arg:
return key_arg
env_key = os.environ.get("ANTHROPIC_API_KEY", "")
if env_key:
return env_key
keys_path = os.path.expanduser("~/.config/lu/keys.json")
if os.path.exists(keys_path):
try:
with open(keys_path) as f:
keys = json.load(f)
for name in ("lu_key", "anthropic_milla", "anthropic_claude_code_main"):
val = keys.get(name, "")
if isinstance(val, str) and val.startswith("sk-ant-"):
return val
for section in ("anthropic", "anthropic_milla", "anthropic_claude_code_main"):
sec = keys.get(section, {})
if isinstance(sec, dict):
for subkey in ("lu_key", "key", "api_key"):
val = sec.get(subkey, "")
if isinstance(val, str) and val.startswith("sk-ant-"):
return val
except Exception:
pass
return ""