fix(auxiliary): pass base_url/api_key to _get_cached_client so multi-endpoint cache keys differ - #64242
fix(auxiliary): pass base_url/api_key to _get_cached_client so multi-endpoint cache keys differ#64242zmlgit wants to merge 2 commits into
Conversation
|
Thanks for tracing the auxiliary routing path. The current implementation does not reproduce the base_url cache collision described in the PR. Problems
Suggested changes
Automated hermes-sweeper review. |
…e_vision_provider_client
b5fd1b1 to
a06980a
Compare
…y path + add regression tests Per teknium1/hermes-sweeper review: the previous commit's narrative described a 'base_url cache collision', but resolve_vision_provider_client short-circuits at line 5594 (the 'if resolved_base_url:' branch) before reaching the bottom _get_cached_client call (line 5772) that the fix touched. So the described collision was unreachable. The actual fix is still correct — for the API-KEY-ONLY path. When _resolve_task_provider_model returns (provider, model, None, api_key, mode) — i.e. config has provider + api_key but no base_url — the function DOES fall through to the bottom _get_cached_client call. Without threading api_key through (as the fix does), two profiles with same provider+model but DIFFERENT api_keys would collide in the cache because the cache key defaults api_key to empty string. Profile B's vision call would resolve to profile A's cached client and authenticate with profile A's key. This commit keeps the code change (already correct) and adds two regression tests that pin the API-key-only contract: - test_vision_api_key_only_path_threads_api_key_into_cache_call: patches _resolve_task_provider_model to return the api-key-only tuple, calls resolve_vision_provider_client, asserts _get_cached_client received api_key='sk_profile_A' (not None — None is the collision bug). - test_vision_api_key_only_cache_keys_differentiate_by_api_key: calls _client_cache_key directly with same provider+model+empty base_url but different api_keys; asserts the keys differ. Sanity-checks that the empty-api_key path (pre-fix shape) is distinct from both, so a regression that drops the api_key thread would re-introduce the collision. All 4 tests in tests/agent/test_vision_resolved_args.py pass; 370 adjacent tests/agent/test_auxiliary_client*.py tests pass.
|
Re-scoped per sweeper review ( On sweeper point 1 ('base_url collision not reproducible'): correct. On sweeper point 2 ('re-scope to API-key-only path'): done. The actual collision vector is API-key-only: when On sweeper point 3 ('add a regression test for that path'): two new tests in
All 4 tests in |
Summary
resolve_vision_provider_clientinagent/auxiliary_client.pycalls_get_cached_client(...)to fetch a cached provider client, but was not passingbase_urlandapi_keyto the cache lookup. As a result, two vision calls with differentbase_url/api_key(e.g. two distinct custom OpenAI-compatible endpoints behind the sameprovider:model) would resolve to the same cached client — the first one registered — silently routing the second call to the wrong endpoint.This PR threads the resolved
base_urlandapi_keyinto_get_cached_clientso the cache key distinguishes clients by endpoint + credentials, not just by provider+model.Why
Cost-correctness for multi-endpoint auxiliary configurations. A common pattern is configuring multiple custom OpenAI-compatible endpoints (e.g. different Azure deployments, different regional gateways) under one provider block, varying only by
base_urlper request. Without this fix the second endpoint is never actually hit — the cached client from the first call is reused.Changes
agent/auxiliary_client.py: passbase_url=resolved_base_url, api_key=resolved_api_key or Noneto_get_cached_client(...)inresolve_vision_provider_client. 2-line addition, no signature change to public APIs.Tests
Local auxiliary suite: 691/692 pass on this branch. The single failure (
test_skill_config_raw_cache_invalidates_on_config_editintest_skill_utils.py) is pre-existing onorigin/mainand unrelated to this change.Backward compatibility
base_url/api_keywere already being computed for the actual client construction, they just weren'"'"'t fed back into the cache key.Related
Companion to #62061 (which addresses
/anthropic-suffix normalization on the same call path). This PR is orthogonal: #62061 normalizes the base_url string before lookup; this PR makes the cache key honor the (already-normalized) base_url + api_key pair.