Repository navigation
Conversation
…irements PR #4083 narrowed exception handlers to `openai.APIError/OpenAIError` and `httpx.HTTPError` in google-adk (generate_a2ui), langroid (handle_run), and strands (generate_a2ui). These imports resolved locally (dev venvs have openai installed) and in CI (the workflow pip-installs openai explicitly) but the Dockerfiles only `pip install -r requirements.txt`, which did not list openai or httpx. Post-merge Railway deploy of google-adk crashed at startup: ModuleNotFoundError: No module named 'openai' at /app/agents/main.py:10 Hotfix: add openai>=1.0.0 and httpx>=0.27.0 to all three packages' requirements.txt. strands-agents[OpenAI] already pulls openai transitively; we pin explicitly for determinism.
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 19, 2026 05:28
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
Contributor
Author
|
Closing in favor of an architectural fix: rewriting google-adk |
jpr5
added a commit
that referenced
this pull request
Apr 19, 2026
The google-adk package's primary agent uses Gemini via google-adk's LlmAgent, but the secondary `generate_a2ui` tool was calling OpenAI's gpt-4.1 through openai.OpenAI(). Cross-provider dependency with no architectural justification — the A2UI planner's function-calling + forced tool-choice pattern works equally well via google.genai. Rewrite to use google.genai.Client.models.generate_content with a ToolConfig forcing the render_a2ui function call (mode="ANY" + allowed_function_names). Drop the openai + httpx direct dependency entirely; google-genai is already pulled in transitively via google-adk and is now pinned explicitly at >=0.8.0. Replaces short-term hotfix PR #4090 (which pinned openai in requirements.txt after post-merge Railway deploy of #4083 crashed with ModuleNotFoundError). Changes: - src/agents/main.py: `_get_openai_client` → `_get_genai_client` (lru_cached google.genai.Client). Rewrote generate_a2ui to build a `types.Tool(function_declarations=[FunctionDeclaration])`, force the call via `types.ToolConfig(function_calling_config=...)` and read the response from `candidates[0].content.parts[*].function_call.args`. Narrowed except clause to `genai_errors.APIError`/`ClientError`/ `ServerError` + `ValueError` (for construction-time failures). A2UI_MODEL env var overrides the default gemini-2.5-flash model. - entrypoint.sh: `OPENAI_API_KEY` guard → `GOOGLE_API_KEY` guard; `REQUIRE_OPENAI_API_KEY` → `REQUIRE_GOOGLE_API_KEY`. - requirements.txt: explicit `google-genai>=0.8.0` pin; no openai, no httpx. - src/app/api/health|debug/route.ts: report GOOGLE_API_KEY status, not OpenAI/Anthropic/LangSmith (this is a Gemini-only package). - playwright.config.ts: inject GOOGLE_API_KEY to the dev server env, not OPENAI_API_KEY / OPENAI_BASE_URL. - tests/python/test_generate_a2ui.py: rewrote 19 tests to mock google.genai.Client in place of openai.OpenAI. Preserves every error branch (a2ui_llm_error, a2ui_empty_response, a2ui_no_tool_call, a2ui_invalid_arguments) plus happy path. Added A2UI_MODEL override coverage. - tests/python/test_entrypoint_env_guards.py: migrated to exercise the GOOGLE_API_KEY / REQUIRE_GOOGLE_API_KEY branch. Verification: - Unit tests: 53 passed locally against Python 3.12 (google-adk + google- genai + all package deps installed). - Docker build: clean (showcase-google-adk:local) via scripts/dev-local.sh. - Container startup: `docker compose up -d google-adk` launches cleanly (no ModuleNotFoundError); uvicorn reports healthy; entrypoint emits the new WARN when GOOGLE_API_KEY is unset. - L1+L2 smoke against local compose: both pass for google-adk. - `import agents.main` inside the container no longer pulls in any `openai.*` module.
5 of 6 tasks
jpr5
added a commit
that referenced
this pull request
Apr 19, 2026
…AI (#4094) ## Summary The google-adk package's primary agent uses Gemini via `google-adk`'s `LlmAgent`, but the secondary `generate_a2ui` tool was calling OpenAI's `gpt-4.1` through `openai.OpenAI()`. Cross-provider dependency with no architectural justification — the A2UI planner's function-calling + forced tool-choice pattern works equally well via `google.genai`. Rewrite to use `google.genai.Client.models.generate_content` with a `ToolConfig` forcing the `render_a2ui` function call (`mode="ANY"` + `allowed_function_names`). Drop the `openai` + `httpx` direct dependency entirely; `google-genai` is already pulled in transitively via `google-adk` and is now pinned explicitly at `>=0.8.0`. Replaces short-term hotfix **PR #4090** (which pinned `openai` in `requirements.txt` after the post-merge Railway deploy of #4083 crashed with `ModuleNotFoundError: No module named 'openai'`). #4090 is already closed; this PR is the architectural correction that keeps the Gemini-primary package on Gemini end-to-end. ## Changes - **`src/agents/main.py`** — `_get_openai_client` → `_get_genai_client` (`lru_cache`'d `google.genai.Client`). Rewrote `generate_a2ui` body to build a `types.Tool(function_declarations=[FunctionDeclaration])`, force the call via `types.ToolConfig(function_calling_config=FunctionCallingConfig(mode="ANY", allowed_function_names=["render_a2ui"]))`, and read the response from `candidates[0].content.parts[*].function_call.args`. Narrowed `except` clause to `genai_errors.APIError`/`ClientError`/`ServerError` + `ValueError` (for construction-time failures). `A2UI_MODEL` env var overrides the default `gemini-2.5-flash` model. - **`entrypoint.sh`** — `OPENAI_API_KEY` guard → `GOOGLE_API_KEY` guard; `REQUIRE_OPENAI_API_KEY` → `REQUIRE_GOOGLE_API_KEY`. Warn / fail-fast semantics preserved. - **`requirements.txt`** — explicit `google-genai>=0.8.0` pin; no `openai`, no `httpx`. - **`src/app/api/health|debug/route.ts`** — report `GOOGLE_API_KEY` status instead of OpenAI/Anthropic/LangSmith (this is a Gemini-only package). - **`playwright.config.ts`** — inject `GOOGLE_API_KEY` to the dev-server env, not `OPENAI_API_KEY` / `OPENAI_BASE_URL`. - **`tests/python/test_generate_a2ui.py`** — rewrote 19 tests to mock `google.genai.Client` in place of `openai.OpenAI`. Preserves every error branch (`a2ui_llm_error`, `a2ui_empty_response`, `a2ui_no_tool_call`, `a2ui_invalid_arguments`) plus the happy path. Added `A2UI_MODEL` override coverage + string-args-parseable-as-JSON fallback. - **`tests/python/test_entrypoint_env_guards.py`** — migrated to exercise the `GOOGLE_API_KEY` / `REQUIRE_GOOGLE_API_KEY` branch. ## Test plan - [x] Unit tests: 53 passed locally (Python 3.12, `google-adk` + `google-genai` + all package deps installed) - [x] `docker build` / `scripts/dev-local.sh build google-adk`: clean - [x] `docker compose up -d google-adk` against latest image: container starts cleanly (no `ModuleNotFoundError`); uvicorn healthy; new WARN emitted when `GOOGLE_API_KEY` unset - [x] `import agents.main` inside the container no longer pulls in any `openai.*` module - [x] L1 (health) + L2 (agent) smoke via `LOCAL_PORTS=1 playwright test integration-smoke -g "google-adk"`: both pass - [ ] L3 (chat) / L4 (tools) smoke: requires a live `GOOGLE_API_KEY`; left to CI / reviewer with secrets
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
The google-adk package's primary agent uses Gemini via google-adk's LlmAgent, but the secondary `generate_a2ui` tool was calling OpenAI's gpt-4.1 through openai.OpenAI(). Cross-provider dependency with no architectural justification — the A2UI planner's function-calling + forced tool-choice pattern works equally well via google.genai. Rewrite to use google.genai.Client.models.generate_content with a ToolConfig forcing the render_a2ui function call (mode="ANY" + allowed_function_names). Drop the openai + httpx direct dependency entirely; google-genai is already pulled in transitively via google-adk and is now pinned explicitly at >=0.8.0. Replaces short-term hotfix PR CopilotKit#4090 (which pinned openai in requirements.txt after post-merge Railway deploy of CopilotKit#4083 crashed with ModuleNotFoundError). Changes: - src/agents/main.py: `_get_openai_client` → `_get_genai_client` (lru_cached google.genai.Client). Rewrote generate_a2ui to build a `types.Tool(function_declarations=[FunctionDeclaration])`, force the call via `types.ToolConfig(function_calling_config=...)` and read the response from `candidates[0].content.parts[*].function_call.args`. Narrowed except clause to `genai_errors.APIError`/`ClientError`/ `ServerError` + `ValueError` (for construction-time failures). A2UI_MODEL env var overrides the default gemini-2.5-flash model. - entrypoint.sh: `OPENAI_API_KEY` guard → `GOOGLE_API_KEY` guard; `REQUIRE_OPENAI_API_KEY` → `REQUIRE_GOOGLE_API_KEY`. - requirements.txt: explicit `google-genai>=0.8.0` pin; no openai, no httpx. - src/app/api/health|debug/route.ts: report GOOGLE_API_KEY status, not OpenAI/Anthropic/LangSmith (this is a Gemini-only package). - playwright.config.ts: inject GOOGLE_API_KEY to the dev server env, not OPENAI_API_KEY / OPENAI_BASE_URL. - tests/python/test_generate_a2ui.py: rewrote 19 tests to mock google.genai.Client in place of openai.OpenAI. Preserves every error branch (a2ui_llm_error, a2ui_empty_response, a2ui_no_tool_call, a2ui_invalid_arguments) plus happy path. Added A2UI_MODEL override coverage. - tests/python/test_entrypoint_env_guards.py: migrated to exercise the GOOGLE_API_KEY / REQUIRE_GOOGLE_API_KEY branch. Verification: - Unit tests: 53 passed locally against Python 3.12 (google-adk + google- genai + all package deps installed). - Docker build: clean (showcase-google-adk:local) via scripts/dev-local.sh. - Container startup: `docker compose up -d google-adk` launches cleanly (no ModuleNotFoundError); uvicorn reports healthy; entrypoint emits the new WARN when GOOGLE_API_KEY is unset. - L1+L2 smoke against local compose: both pass for google-adk. - `import agents.main` inside the container no longer pulls in any `openai.*` module.
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
…AI (CopilotKit#4094) ## Summary The google-adk package's primary agent uses Gemini via `google-adk`'s `LlmAgent`, but the secondary `generate_a2ui` tool was calling OpenAI's `gpt-4.1` through `openai.OpenAI()`. Cross-provider dependency with no architectural justification — the A2UI planner's function-calling + forced tool-choice pattern works equally well via `google.genai`. Rewrite to use `google.genai.Client.models.generate_content` with a `ToolConfig` forcing the `render_a2ui` function call (`mode="ANY"` + `allowed_function_names`). Drop the `openai` + `httpx` direct dependency entirely; `google-genai` is already pulled in transitively via `google-adk` and is now pinned explicitly at `>=0.8.0`. Replaces short-term hotfix **PR CopilotKit#4090** (which pinned `openai` in `requirements.txt` after the post-merge Railway deploy of CopilotKit#4083 crashed with `ModuleNotFoundError: No module named 'openai'`). CopilotKit#4090 is already closed; this PR is the architectural correction that keeps the Gemini-primary package on Gemini end-to-end. ## Changes - **`src/agents/main.py`** — `_get_openai_client` → `_get_genai_client` (`lru_cache`'d `google.genai.Client`). Rewrote `generate_a2ui` body to build a `types.Tool(function_declarations=[FunctionDeclaration])`, force the call via `types.ToolConfig(function_calling_config=FunctionCallingConfig(mode="ANY", allowed_function_names=["render_a2ui"]))`, and read the response from `candidates[0].content.parts[*].function_call.args`. Narrowed `except` clause to `genai_errors.APIError`/`ClientError`/`ServerError` + `ValueError` (for construction-time failures). `A2UI_MODEL` env var overrides the default `gemini-2.5-flash` model. - **`entrypoint.sh`** — `OPENAI_API_KEY` guard → `GOOGLE_API_KEY` guard; `REQUIRE_OPENAI_API_KEY` → `REQUIRE_GOOGLE_API_KEY`. Warn / fail-fast semantics preserved. - **`requirements.txt`** — explicit `google-genai>=0.8.0` pin; no `openai`, no `httpx`. - **`src/app/api/health|debug/route.ts`** — report `GOOGLE_API_KEY` status instead of OpenAI/Anthropic/LangSmith (this is a Gemini-only package). - **`playwright.config.ts`** — inject `GOOGLE_API_KEY` to the dev-server env, not `OPENAI_API_KEY` / `OPENAI_BASE_URL`. - **`tests/python/test_generate_a2ui.py`** — rewrote 19 tests to mock `google.genai.Client` in place of `openai.OpenAI`. Preserves every error branch (`a2ui_llm_error`, `a2ui_empty_response`, `a2ui_no_tool_call`, `a2ui_invalid_arguments`) plus the happy path. Added `A2UI_MODEL` override coverage + string-args-parseable-as-JSON fallback. - **`tests/python/test_entrypoint_env_guards.py`** — migrated to exercise the `GOOGLE_API_KEY` / `REQUIRE_GOOGLE_API_KEY` branch. ## Test plan - [x] Unit tests: 53 passed locally (Python 3.12, `google-adk` + `google-genai` + all package deps installed) - [x] `docker build` / `scripts/dev-local.sh build google-adk`: clean - [x] `docker compose up -d google-adk` against latest image: container starts cleanly (no `ModuleNotFoundError`); uvicorn healthy; new WARN emitted when `GOOGLE_API_KEY` unset - [x] `import agents.main` inside the container no longer pulls in any `openai.*` module - [x] L1 (health) + L2 (agent) smoke via `LOCAL_PORTS=1 playwright test integration-smoke -g "google-adk"`: both pass - [ ] L3 (chat) / L4 (tools) smoke: requires a live `GOOGLE_API_KEY`; left to CI / reviewer with secrets
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hotfix for #4083 post-merge: google-adk Railway deploy crashed at startup with
ModuleNotFoundError: No module named 'openai'. Langroid would crash on next rebuild (same issue, module-level imports). Strands is lazy-imported so was unaffected but pinned for determinism.Root cause
#4083 narrowed exception handlers in:
showcase/packages/google-adk/src/agents/main.py(top-levelimport openai)showcase/packages/langroid/src/agents/agui_adapter.py(top-levelimport openai; import httpx)showcase/packages/strands/src/agents/agent.py(lazyimport openai as _openai_mod)Imports resolved locally (dev venvs have openai) and in CI (workflow pip-installs openai explicitly for tests) but each package's Dockerfile only runs
pip install -r requirements.txtwhich didn't list openai/httpx.Fix
Add
openai>=1.0.0+httpx>=0.27.0to requirements.txt for all three packages.Verification
77074a16FAILED with the traceback above; will rebuild clean with this hotfix.Test plan