diff --git a/tests/tools/test_startup_latency_regressions.py b/tests/tools/test_startup_latency_regressions.py index 439dd1083a..9a793ed217 100644 --- a/tests/tools/test_startup_latency_regressions.py +++ b/tests/tools/test_startup_latency_regressions.py @@ -34,40 +34,25 @@ class TestAuxProbeMode: with aux._client_cache_lock: assert key not in aux._client_cache - def test_probe_stub_never_cached_via_get_cached_client(self): - """The inline store in _get_cached_client must honour the same guard. - - test_probe_stub_never_cached above covers _store_cached_client(), but - _get_cached_client() assigns to _client_cache directly instead of - calling it. That is the path check_fns actually take inside - aux_probe_mode(), so without a guard there the probe poisons the entry - and the next runtime caller with the same key gets a dead client. + @pytest.mark.parametrize("wrap", [False, True], ids=["bare-stub", "adapter-wrapped-stub"]) + def test_repeat_probes_stay_resolvable_and_never_cache(self, wrap): + """Probes go through _get_cached_client's inline store, not _store_cached_client, + so the stub (bare, or wrapped in a Codex adapter whose leaf is the stub) used to + land under the runtime key; the next probe then hit _compat_model() on the stub + and check_vision_requirements() flipped to False for the process (#87654). """ import agent.auxiliary_client as aux - stub = aux._AuxProbeClientStub() - try: - with patch.object( - aux, "resolve_provider_client", lambda *a, **k: (stub, "m") - ): - with aux.aux_probe_mode(): - client, _model = aux._get_cached_client("probe-guard-test", "m") - assert client is stub - with aux._client_cache_lock: - poisoned = [ - key - for key, entry in aux._client_cache.items() - if isinstance(entry[0], aux._AuxProbeClientStub) - ] - assert poisoned == [], f"probe stub reached the cache: {poisoned}" - finally: - with aux._client_cache_lock: - for key in [ - k - for k, e in aux._client_cache.items() - if isinstance(e[0], aux._AuxProbeClientStub) - ]: - del aux._client_cache[key] + def _resolve(*a, **k): + stub = aux._AuxProbeClientStub(api_key="k", base_url="https://x.invalid/v1") + return (aux.CodexAuxiliaryClient(stub, "v/m") if wrap else stub), "v/m" + + aux.shutdown_cached_clients() + with patch.object(aux, "resolve_provider_client", _resolve), aux.aux_probe_mode(): + answers = [aux._get_cached_client("probe-guard-test", "vendor/model")[0] is not None for _ in range(3)] + assert answers == [True, True, True] + with aux._client_cache_lock: + assert not [k for k in aux._client_cache if k[1:2] == (False,) and k[-1] == "vendor/model"] def test_probe_stub_raises_on_runtime_use(self): import agent.auxiliary_client as aux