Repository navigation
fix(adk): give each new A2UI surface an id of its own - #3396
AlemTuzlak wants to merge 2 commits into
Conversation
Every create without a target used the toolkit default surface id dynamic-surface. A client that keys surfaces by id (CopilotKit 2.x) then replaced the previous dashboard with each new one. Without a host default_surface_id, a create now gets dynamic-surface-<8 hex>. An update keeps the surface it targets, and a host default_surface_id keeps its meaning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Python Preview PackagesVersion
Install with uvAdd the TestPyPI index to your [[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = trueThen install the packages you need: # Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1794584479' --index testpypi
# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1794584479' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1794584479' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1794584479' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1794584479' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1794584479' --index testpypiInstall with pippip install \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
ag-ui-protocol==0.0.0.dev1794584479
Commit: 10ee533 |
@ag-ui/a2a-middleware
@ag-ui/a2ui-middleware
@ag-ui/event-throttle-middleware
@ag-ui/mcp-apps-middleware
@ag-ui/mcp-middleware
@ag-ui/a2a
@ag-ui/adk-js
@ag-ui/adk
@ag-ui/ag2
@ag-ui/agno
@ag-ui/antigravity
@ag-ui/aws-strands
@ag-ui/claude-agent-sdk
@ag-ui/claude-managed-agents
@ag-ui/crewai
@ag-ui/langchain
@ag-ui/langgraph
@ag-ui/llamaindex
@ag-ui/mastra
@ag-ui/openai-agents
@ag-ui/pydantic-ai
@ag-ui/vercel-ai-sdk
@ag-ui/watsonx
@ag-ui/a2ui-toolkit
create-ag-ui-app
@ag-ui/client
@ag-ui/core
@ag-ui/encoder
@ag-ui/proto
commit: |
A random id differed on every run, so a replayed run (a recorded fixture) could never name the surface. The tool call id is unique for each dashboard and the same on every replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
surlymochan
left a comment
There was a problem hiding this comment.
Reviewed the diff and the two new tests (read the file at the PR head, 5e88874).
Verified:
- The fix does what the title says: with no host
default_surface_id, each create gets{default}-{function_call_id}(test pinsdynamic-surface-first-call/dynamic-surface-second-call), so a CopilotKit client keying surfaces by id shows two dashboards instead of replacing the first. The host-default test pins["report"], so a host default keeps its meaning, and an explicittarget_surface_idstill wins on both paths. uuidis imported at line 23, so the fallback cannot NameError.
One gap worth a look: the comment says "The id comes from the tool call, so a replayed run (a recorded fixture) gets the same id", but that holds only when function_call_id is present. When it is None, the fallback is uuid.uuid4().hex[:8], which is random per run, so a replayed fixture without a call id gets a different surface id each time (and the test only covers the present-call-id path). Is function_call_id guaranteed non-None on this path in ADK? If not, either the comment should scope the replay guarantee to the present-call-id case, or the fallback should derive from something stable already in scope. Not blocking, just a determinism note.
Every ADK A2UI dashboard in a thread used the same surface id,
dynamic-surface. When the host sets nodefault_surface_id, each create without a target falls back to the toolkit default. CopilotKit 2.x shows one card per surface id, so each new dashboard replaced the previous one, and the user lost the earlier dashboard. Now a create without a target getsdynamic-surface-<tool call id>when the host sets nodefault_surface_id.What changed
run_asyncpicks the surface id once:target_surface_iduses it, as before.<default>-<tool call id>when the host set nodefault_surface_id. Without a tool call id, it gets 8 random hex characters.default_surface_id, creates use it, as before.get_a2ui_toolrecords whether the host set one. The auto-injected tool sets none, so it gets the new ids.Testing
Commands run
uv run --locked pytestinintegrations/adk-middleware/python: 1536 pass, 9 skipped.black --checkon the changed files passes.The two new tests fail without the source change and pass with it.
End to end: I installed this PR's TestPyPI preview of
ag-ui-adkin the CopilotKit showcasegoogle-adkapp on CopilotKit2.0.0-rc.46. The 4 dashboard pills in one thread gave 4 chat cards (dynamic-surface-call_d6_decl_dash_outer_001and so on) and no error alert. For this run, the recorded Express fixtures named the new ids.Manual test
google-adk:declarative-gen-uion CopilotKit 2.x withag-ui-adk0.12.0. The second pill replaces the first dashboard, so the probe finds no newBarChart.How this PR makes testing easy:
tests/test_a2ui_express_update_snapshots.pyhas two new tests: two creates without a host default get the ids of their tool calls, and a create with a host default keeps it.Risk / rollback
surface("dynamic-surface", update=true)must name the new id,dynamic-surface-<tool call id>.dynamic-surfaceafter a create no longer finds it. An update without a target still usesdynamic-surface, so it does not find a surface that a create made without a host default. Name the target, or setdefault_surface_id, for that flow.render_a2uicall, so this does not change them.🤖 Generated with Claude Code