Commit Graph

4 Commits

Author SHA1 Message Date
Jordan Ritter 2482317ccc style: apply ruff format to Python codebase
320 files reformatted. One-time alignment to match the ruff format
check added to CI in #4812.
2026-05-13 23:10:35 -07:00
Alem Tuzlak 4670d25a78 fix(showcase/google-adk): break Gemini tool loop, align agent IDs, A2UI v0.9 shape
Brings the Google ADK showcase back to parity with the langgraph-python
north-star across the 14 issues catalogued in PR #4792's TL;DR. Four
independent classes of bug fixed; all 36 demos now route, terminate, and
render correctly against real Gemini.

1. Universal Gemini infinite tool loop
   ADK's LlmAgent does not naturally terminate after a tool result with
   Gemini 2.5-flash — every backend or frontend tool fired forever. Lifted
   the (orphaned) `simple_after_model_modifier` from agents/main.py into
   shared_chat.stop_on_terminal_text without the SalesPipelineAgent
   name-gate; wired it as `after_model_callback=` into every registered
   LlmAgent (22 dedicated agents plus the build_simple_chat_agent /
   build_thinking_chat_agent factories). simple_after_model_modifier is
   kept as a thin alias so the existing test file keeps resolving.

2. Stale @ag-ui/client trapped on deprecated event names
   ag_ui_adk v0.6.1 emits the canonical REASONING_* events but the
   integration's package.json pinned `@ag-ui/client: ^0.0.43` which under
   npm's pre-1.0 caret rule resolves to strictly 0.0.43 — a version that
   only knows the deprecated THINKING_* names. Every Gemini response
   tripped the runtime's Zod discriminator. Bumped to ^0.0.53 and
   regenerated the lockfile.

3. Frontend agent IDs out of sync with backend mounts
   page.tsx for hitl-in-chat / frontend-tools-async / prebuilt-popup
   declared underscored agent IDs that didn't appear in the runtime's
   agent map, so useAgent threw "Agent not found after runtime sync"
   and the React tree crashed. Renamed to the dashed form that matches
   the registry. MCP Apps had the same class of bug at the route level —
   copilotkit-mcp-apps/route.ts pointed HttpAgent at /mcp_apps but the
   FastAPI mount is /mcp-apps; fixed to dash.

4. A2UI ops in deprecated v0.8 flat shape
   tools/generate_a2ui.py:build_a2ui_operations_from_tool_call,
   tools/search_flights.py, and agents/a2ui_fixed_agent.py emitted
   `{type: "create_surface", surfaceId, ...}` (flat). The
   @ag-ui/a2ui-middleware matcher only walks the v0.9 nested keys
   (`{createSurface: {surfaceId, ...}}`), so every op was grouped under
   the fallback "default" surface and the renderer threw
   `Catalog not found: default` or
   `Component 'undefined' is missing an 'id'`. Rewrote to v0.9 nested
   shape with `version: "v0.9"` and `updateDataModel` using `path` +
   `value` (matching copilotkit.a2ui Python helper).

   Three follow-on fixes in agents/main.py and beautiful_chat_agent.py
   that surfaced once the structural fix landed:
   - _AGENT_NAME_TO_CATALOG_ID table + _resolve_pinned_catalog_id helper:
     Gemini hallucinated catalog IDs because the schema for catalogId
     was unconstrained; the north-star hardcodes CUSTOM_CATALOG_ID per
     agent file, mirrored here with a name to id table so one shared
     generate_a2ui dispatches per demo.
   - Tightened parametersJsonSchema for components.items to require
     id + component AND explicitly declare the optional text / label /
     value / children / child / data props. Gemini's structured-output
     path drops fields not in the schema even with default
     additionalProperties: true, which produced [{}, {}, {}].
   - Hard-requirements prompt prefix with a concrete PieChart example
     ported from langgraph-python's _GENERATE_A2UI_PROMPT_HEADER, plus
     _sanitize_a2ui_components / _has_root_component validators and
     _unstringify_json_fields to round-trip Gemini's quirk of emitting
     "data": "[{...}]" as a JSON string instead of an actual array.

Windows note: the integration's tools/ symlink does not materialize on
Windows worktrees (git stores it as mode 100644). The local copies under
showcase/integrations/google-adk/tools/ are kept byte-identical to the
canonical sources under showcase/shared/python/tools/. On Linux/macOS
where the symlink works, only the shared/ copy is authoritative.
2026-05-13 17:11:16 +02:00
Jordan Ritter cffecf1fc1 fix: resolve 3 starter crash root causes — Docker home dir, path depth, import rewriting
1. EACCES on /home/app: Dockerfile templates now create home dir for
   non-root user before USER app (langgraph-ts, claude-sdk-ts, mastra)
2. IndexError Path.parents[4]: search_flights.py schema fallback now
   guards against shallow Docker paths (agno, claude-sdk-py, ms-agent-py)
3. Wrong import path: rewritePythonImports() now converts
   from agents.X to relative imports in starter agent dirs (langroid, crewai)
2026-04-15 09:27:08 -07:00
Jordan Ritter 25ee60e0dd feat: add shared showcase packages with tools, components, and test coverage
- @copilotkit/showcase-shared: React hooks, components, A2UI catalog, SalesDashboard
- Shared Python tools: 7 implementations + 54 pytest tests
- Shared TypeScript tools: equivalents + 43 vitest tests
- React component tests: 68 tests (7 suites)
- Aimock fixtures: 18 deterministic demo scenarios
2026-04-13 17:38:44 -07:00