fix: preserve Google LLM fallback timeouts#5999
Conversation
| if is_given(self._llm._opts.http_options): | ||
| http_options = self._llm._opts.http_options.model_copy(deep=True) | ||
| else: | ||
| http_options = types.HttpOptions() | ||
| if http_options.timeout is None: | ||
| http_options.timeout = int(self._conn_options.timeout * 1000) |
There was a problem hiding this comment.
🚩 Realtime API has the same mutation bug that this PR fixes in LLM
The realtime_api.py:465-472 still uses the old or pattern without deep copy:
http_options = self._opts.http_options or types.HttpOptions(
timeout=int(self._opts.conn_options.timeout * 1000)
)This mutates the original self._opts.http_options object when adding headers at line 471-472 and setting api_version at line 469. While the header mutation is idempotent (same key overwritten with same value), the api_version mutation could be more consequential if the model is reused across sessions with different api_version requirements. The same fix applied here (deep copy + timeout merge) should likely be applied to realtime_api.py as well.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Closing because current main now preserves caller HTTP options and only fills in the connection timeout when the caller left it unset. Main also copies the headers before adding the LiveKit client header, which is stricter than this branch by avoiding mutation of caller-owned data. The original timeout-loss bug is therefore already fixed upstream. |
Fixes #5972.
Summary
HttpOptionswhile injecting LiveKit connection timeouts when no timeout is setGenerateContentConfigTo verify
PYTHONPATH=livekit-agents;livekit-plugins/livekit-plugins-google python -m pytest tests/test_plugin_google_llm.py -qpython -m ruff check livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py tests/test_plugin_google_llm.pypython -m ruff format --check livekit-plugins/livekit-plugins-google/livekit/plugins/google/llm.py tests/test_plugin_google_llm.pygit diff --check