Repository navigation
fix(showcase/google-adk): use Gemini for A2UI planner instead of OpenAI - #4094
Merged
Merged
Conversation
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
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
April 19, 2026 14:56
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Contributor
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
1 of 2 tasks
jpr5
added a commit
that referenced
this pull request
Apr 19, 2026
…action
The GenerateA2UITool previously hardcoded openai.OpenAI() + gpt-4.1,
which meant non-OpenAI users still needed OPENAI_API_KEY even though
langroid itself is provider-agnostic (LANGROID_MODEL picks provider).
Route the A2UI planner through lm.OpenAIGPT — langroid's universal LLM
abstraction that dispatches to OpenAI / Anthropic / Gemini / any
provider based on the chat_model prefix. A2UI_MODEL env overrides only
the planner model; otherwise inherits from LANGROID_MODEL (default
openai/gpt-4.1).
Adds _A2uiError TypedDict + _a2ui_error constructor to match the error
shape used by sibling google-adk and strands agents. Every failure
branch (LLM exception, no tool call, malformed arguments, non-dict
arguments) now returns a structured {error, message, remediation} dict
instead of leaking provider exceptions. Programmer errors
(AttributeError, TypeError, NameError, SyntaxError) propagate so
regressions are caught in test and server logs.
Sibling to #4094 (google-adk); same smell, softer surface here since
langroid is already multi-provider — this PR just finishes the
abstraction.
4 of 6 tasks
jpr5
added a commit
that referenced
this pull request
Apr 19, 2026
…4097) ## MERGE ASAP — main is RED `Showcase validate` / `Run validate-pins (ratchet)` is failing on main after PR #4095 (agno SDK upgrade) merged. This PR unblocks main CI. ## What drifted Pure **set drift** — count unchanged, hash differs: | field | before | after | | --- | --- | --- | | `validatePinsFailCount` | 110 | **110** (unchanged) | | `validatePinsFailHash` | `c87ecdd6…a45560` | `958bcf24…4ae17` | From failing run [24632821166](https://github.com/CopilotKit/CopilotKit/actions/runs/24632821166): ``` validate-pins FAIL: actual=110 baseline=110 validate-pins HASH: actual=958bcf24c27cef69d7856e12deafe92073af7ad716289b2f6e4418827264ae17 baseline=c87ecdd6cc0829f8ef93c6e3cc4bb30aa3a577f99c5c8e9349b7c2dc78a45560 ``` ## Why PR #4095 (`fix(showcase/agno): upgrade agno SDK to 2.5.17`) ratcheted the hash against its own branch state, but other PRs merged in between (#4094 google-adk, #4092 chown, etc.) shifted the baseline further. End result: one `[FAIL]` healed while another regressed — net zero on the counter but the failing tuples changed, so the hash no longer matches. ## What this PR does Re-ratchets `showcase/scripts/fail-baseline.json` to the hash currently produced by main. Count stays at 110. ## Risk Minimal. Single field change in a JSON baseline file. No workflow edits. No source changes. Does not hide new regressions — if any NEW failure appears after this merges, the count (not just the hash) will bump and CI will catch it. ## Test plan - [x] Extracted actual hash from failing run output, not guessed - [ ] CI green after merge (unblocks main)
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
zeekay
pushed a commit
to Dream-AI-4444/CopilotKit
that referenced
this pull request
Sep 11, 2026
…opilotKit#4097) ## MERGE ASAP — main is RED `Showcase validate` / `Run validate-pins (ratchet)` is failing on main after PR CopilotKit#4095 (agno SDK upgrade) merged. This PR unblocks main CI. ## What drifted Pure **set drift** — count unchanged, hash differs: | field | before | after | | --- | --- | --- | | `validatePinsFailCount` | 110 | **110** (unchanged) | | `validatePinsFailHash` | `c87ecdd6…a45560` | `958bcf24…4ae17` | From failing run [24632821166](https://github.com/CopilotKit/CopilotKit/actions/runs/24632821166): ``` validate-pins FAIL: actual=110 baseline=110 validate-pins HASH: actual=958bcf24c27cef69d7856e12deafe92073af7ad716289b2f6e4418827264ae17 baseline=c87ecdd6cc0829f8ef93c6e3cc4bb30aa3a577f99c5c8e9349b7c2dc78a45560 ``` ## Why PR CopilotKit#4095 (`fix(showcase/agno): upgrade agno SDK to 2.5.17`) ratcheted the hash against its own branch state, but other PRs merged in between (CopilotKit#4094 google-adk, CopilotKit#4092 chown, etc.) shifted the baseline further. End result: one `[FAIL]` healed while another regressed — net zero on the counter but the failing tuples changed, so the hash no longer matches. ## What this PR does Re-ratchets `showcase/scripts/fail-baseline.json` to the hash currently produced by main. Count stays at 110. ## Risk Minimal. Single field change in a JSON baseline file. No workflow edits. No source changes. Does not hide new regressions — if any NEW failure appears after this merges, the count (not just the hash) will bump and CI will catch it. ## Test plan - [x] Extracted actual hash from failing run output, not guessed - [ ] CI green after merge (unblocks main)
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
The google-adk package's primary agent uses Gemini via
google-adk'sLlmAgent, but the secondarygenerate_a2uitool was calling OpenAI'sgpt-4.1throughopenai.OpenAI(). Cross-provider dependency with no architectural justification — the A2UI planner's function-calling + forced tool-choice pattern works equally well viagoogle.genai.Rewrite to use
google.genai.Client.models.generate_contentwith aToolConfigforcing therender_a2uifunction call (mode="ANY"+allowed_function_names). Drop theopenai+httpxdirect dependency entirely;google-genaiis already pulled in transitively viagoogle-adkand is now pinned explicitly at>=0.8.0.Replaces short-term hotfix PR #4090 (which pinned
openaiinrequirements.txtafter the post-merge Railway deploy of #4083 crashed withModuleNotFoundError: 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'dgoogle.genai.Client). Rewrotegenerate_a2uibody to build atypes.Tool(function_declarations=[FunctionDeclaration]), force the call viatypes.ToolConfig(function_calling_config=FunctionCallingConfig(mode="ANY", allowed_function_names=["render_a2ui"])), and read the response fromcandidates[0].content.parts[*].function_call.args. Narrowedexceptclause togenai_errors.APIError/ClientError/ServerError+ValueError(for construction-time failures).A2UI_MODELenv var overrides the defaultgemini-2.5-flashmodel.entrypoint.sh—OPENAI_API_KEYguard →GOOGLE_API_KEYguard;REQUIRE_OPENAI_API_KEY→REQUIRE_GOOGLE_API_KEY. Warn / fail-fast semantics preserved.requirements.txt— explicitgoogle-genai>=0.8.0pin; noopenai, nohttpx.src/app/api/health|debug/route.ts— reportGOOGLE_API_KEYstatus instead of OpenAI/Anthropic/LangSmith (this is a Gemini-only package).playwright.config.ts— injectGOOGLE_API_KEYto the dev-server env, notOPENAI_API_KEY/OPENAI_BASE_URL.tests/python/test_generate_a2ui.py— rewrote 19 tests to mockgoogle.genai.Clientin place ofopenai.OpenAI. Preserves every error branch (a2ui_llm_error,a2ui_empty_response,a2ui_no_tool_call,a2ui_invalid_arguments) plus the happy path. AddedA2UI_MODELoverride coverage + string-args-parseable-as-JSON fallback.tests/python/test_entrypoint_env_guards.py— migrated to exercise theGOOGLE_API_KEY/REQUIRE_GOOGLE_API_KEYbranch.Test plan
google-adk+google-genai+ all package deps installed)docker build/scripts/dev-local.sh build google-adk: cleandocker compose up -d google-adkagainst latest image: container starts cleanly (noModuleNotFoundError); uvicorn healthy; new WARN emitted whenGOOGLE_API_KEYunsetimport agents.maininside the container no longer pulls in anyopenai.*moduleLOCAL_PORTS=1 playwright test integration-smoke -g "google-adk": both passGOOGLE_API_KEY; left to CI / reviewer with secrets