Skip to content

The agent that grows with you

fix(aux): keep a scoped runtime's key rotation out of the legacy mirrors

kshitijk4poor325c9a2f26c1
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 27b34bd470a..32510883702 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -2795,7 +2795,9 @@ def rotate_runtime_main_api_key(old: Any, new: Any) -> None:
runtime = _RUNTIME_MAIN_CONTEXT.get()
if isinstance(runtime, dict) and runtime.get("api_key") == old:
runtime["api_key"] = _normalize_api_key(new)
- _publish_runtime_main_mirrors(tuple(runtime[field] for field in _MAIN_RUNTIME_FIELDS))
+ # A scoped runtime is a normalized copy (empty fields dropped) that must not reach the mirrors.
+ if _RUNTIME_MAIN_API_KEY == old:
+ _publish_runtime_main_mirrors(tuple(runtime.get(field, "") for field in _MAIN_RUNTIME_FIELDS))
def reset_runtime_main(token: contextvars.Token) -> None: