Skip to content

The agent that grows with you

refactor(agent/gemini): restore GeminiNativeClient context-manager surface (OpenAI-client duck type)

Tekniumfc48d6c8d064
diff --git a/agent/gemini_native_adapter.py b/agent/gemini_native_adapter.py
index fb693723c07..0d2af89f4a2 100644
--- a/agent/gemini_native_adapter.py
+++ b/agent/gemini_native_adapter.py
@@ -614,6 +614,13 @@ class GeminiNativeClient:
with contextlib.suppress(Exception):
self._http.close()
+ # OpenAI-client duck-type surface: callers may use ``with client:``.
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.close()
+
def _headers(self) -> Dict[str, str]:
return {"Content-Type": "application/json", "Accept": "application/json", "x-goog-api-key": self.api_key,
"User-Agent": f"{_API_CLIENT} (gemini-native)", "X-Goog-Api-Client": _API_CLIENT, **self._default_headers}