Skip to content

fix(showcase): pin openai + httpx in google-adk/langroid/strands requirements - #4090

Closed
jpr5 wants to merge 1 commit into
mainfrom
fix/showcase-openai-requirements
Closed

jpr5 wants to merge 1 commit into
mainfrom
fix/showcase-openai-requirements

Conversation

@jpr5

@jpr5 jpr5 commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

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-level import openai)
  • showcase/packages/langroid/src/agents/agui_adapter.py (top-level import openai; import httpx)
  • showcase/packages/strands/src/agents/agent.py (lazy import 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.txt which didn't list openai/httpx.

Fix

Add openai>=1.0.0 + httpx>=0.27.0 to requirements.txt for all three packages.

Verification

  • google-adk: Railway deploy 77074a16 FAILED with the traceback above; will rebuild clean with this hotfix.
  • Existing unit tests cover the exception-handling paths (google-adk 42, langroid 31, strands 40+ tests).

Test plan

  • Railway redeploy of showcase-google-adk returns to healthy
  • Post-merge smoke tests pass on Railway for all three packages

…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.
@vercel

vercel Bot commented Apr 19, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat-with-your-data Ready Ready Preview, Comment Apr 19, 2026 5:32am
docs Ready Ready Preview, Comment Apr 19, 2026 5:32am
form-filling Ready Ready Preview, Comment Apr 19, 2026 5:32am
research-canvas Ready Ready Preview, Comment Apr 19, 2026 5:32am
travel Ready Ready Preview, Comment Apr 19, 2026 5:32am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@jpr5

jpr5 commented Apr 19, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of an architectural fix: rewriting google-adk generate_a2ui to use Gemini (google.genai) instead of OpenAI, eliminating the cross-provider dependency entirely. Langroid + strands keep OpenAI (langroid is provider-agnostic; strands' primary model is OpenAI). See follow-up PR.

@jpr5 jpr5 closed this Apr 19, 2026
@jpr5
jpr5 deleted the fix/showcase-openai-requirements branch April 19, 2026 14:42
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.
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

5 active deployments
Preview – docs — 6422dc26 Deployed Apr 19, 2026 by vercel[bot]
Preview – research-canvas — 6422dc26 Deployed Apr 19, 2026 by vercel[bot]
Preview – travel — 6422dc26 Deployed Apr 19, 2026 by vercel[bot]
Preview – form-filling — 6422dc26 Deployed Apr 19, 2026 by vercel[bot]
Preview – chat-with-your-data — 6422dc26 Deployed Apr 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant