Skip to content

chore(deps): bump @ag-ui to the #2350 subagent-events previews - #6757

Closed
mme wants to merge 7 commits into
mainfrom
mme/bump-ag-ui-subagent-events
Closed

mme wants to merge 7 commits into
mainfrom
mme/bump-ag-ui-subagent-events

Conversation

@mme

@mme mme commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Draft, preview-build vehicle. This is CopilotKit PR #5873 minus the SubagentRegistry and useSubagent hook (331 lines removed) — only the dependency work remains:

Why the hook was dropped

The AG-UI dojo demo (ag-ui-protocol/ag-ui#2351) was useSubagent's only consumer, and it turned out to need almost nothing from it: the hook supplied a label, a tooltip and a status dot, while all the actual subagent UI work (grouping, anchoring, hiding attributed messages) lived in the demo reading message.subagentRunId directly. The demo now tracks the lifecycle itself via the AgentSubscriber callbacks (~60 lines), so the dojo only needs a CopilotKit build that bundles the new @ag-ui/client — this PR.

The registry/hook (untested, no other consumer) can return as its own PR if demand for a first-class hook materializes; the removed code lives on mme/subagents / #5873 for salvage.

Lifecycle

Like the pins it replaces, this is temporary: swap the overrides for released @ag-ui versions once ag-ui#2350 merges and ships. The dojo pins this PR's preview builds by commit sha (tracked in PNI-275).

Verified: @copilotkit/core and @copilotkit/react-core check-types + test green via nx after the removal, with no remaining references to the registry, hook, or onSubagentsChanged.

mme and others added 7 commits July 8, 2026 14:52
Track subagent lifecycle (SUBAGENT_STARTED/FINISHED/ERROR) per owning agent
in a new SubagentRegistry delegate on CopilotKitCore, exposed via
getSubagents(agentId) and an onSubagentsChanged subscription. Add a
useSubagent({ subagentId | subagentName, agentId? }) hook to resolve a
message's subagentId to a name, description, and running status, warning
once (dev) when a subagentName is ambiguous.

Requires @ag-ui/client + @ag-ui/core >= 0.0.58; bumps the pins accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
AG-UI renamed the subagent attribution field because the old name implied
a reusable subagent DEFINITION when the value identifies one INVOCATION --
two runs of the same subagent get two different values. See
ag-ui-protocol/ag-ui#2350.

  subagentId       -> subagentRunId
  parentSubagentId -> parentSubagentRunId

Applied to both sides of this package's surface:

- Reading the wire. SubagentRegistry consumes `event.subagentRunId` from
  SUBAGENT_STARTED / FINISHED / ERROR. This is the part that MUST move: the
  events are typed as SubagentStartedEvent etc. from @ag-ui/core, so
  against the renamed protocol the old field simply is not there and the
  registry would silently stay empty -- every subagent lookup returning
  undefined, with no error.
- CopilotKit's own API. `useSubagent({ subagentRunId })` and
  `SubagentState.subagentRunId`. Renaming these is what makes the API
  self-consistent: the hook already distinguishes `subagentRunId` (exact,
  one invocation) from `subagentName` (the declared `subagent_type`, not
  unique), which is precisely the definition-vs-invocation split the old
  name blurred.

This is a breaking change to `useSubagent`, taken now because the hook has
never shipped -- it exists only on this unmerged branch, so there is no
released consumer to migrate and no alias to maintain.

The @Ag-ui override repin is in the same commit rather than a separate
`chore(deps)` one because the two are atomically coupled: the rename cannot
typecheck against the old canaries, and the repin alone would leave the
registry reading a field the stream no longer emits. Splitting them would
mean one commit that is definitely broken either way.

Verified: @copilotkit/core and @copilotkit/react-core typecheck against the
renamed protocol, and react-core's 1424 tests pass. The typecheck is
load-bearing here, not incidental -- injecting a deliberately wrong field
name produces 5 TS errors, so a green check really does prove the field
matches @ag-ui/core's types.

Note: the registry and hook still have no test coverage of their own; the
only subagent assertions live downstream in the AG-UI dojo demo.
The lockfile installed TWO incompatible copies of the protocol: the PR-2350
preview carrying `subagentRunId`, and the old `0.0.59-canary.1785518626.0`
carrying `subagentId`. Any subagent-attributed event passing through a package
bound to the canary copy lost its attribution silently -- the registry would read
a field the stream no longer emits, so every lookup returned undefined with no
error. Reported in review of the rename commit.

The cause is peer auto-install, which took a while to find. `pnpm.overrides`
governs DECLARED dependencies. `@ag-ui/langgraph`, `@ag-ui/a2a` and
`@ag-ui/mcp-apps-middleware` declare `@ag-ui/core` / `@ag-ui/client` as PEERS,
and four workspace packages depended on them without declaring those peers
themselves -- so pnpm auto-installed the peers straight from the registry,
resolving to the canary and bypassing the overrides. That is why the overrides
looked ignored: they were never consulted for those edges.

Fixed the conventional way, by declaring the peers so they resolve from the graph
instead of being fetched:

- `packages/sdk-js` -- @ag-ui/core, @ag-ui/client
- `examples/v2/angular/demo-server` -- @ag-ui/core, @ag-ui/client
- `examples/showcases/generative-ui-playground` -- @ag-ui/core
- `examples/v2/vue/demo` -- @ag-ui/client (it declared mcp-apps-middleware but no
  client, which was the last remaining edge)

Result: zero references to the canary in the lockfile, and exactly ONE
@ag-ui/core installed -- the renamed preview. Verified by deleting the stale
store directories and reinstalling from the committed lockfile alone: they are
not recreated, so nothing can reach the old copy.

Things that did NOT work, recorded so they are not retried: plain install,
`--force`, `pnpm dedupe`, `>`-scoped overrides (`@ag-ui/a2a>@ag-ui/core`),
version-specific overrides, and deleting the lockfile to regenerate from scratch
-- which reproduced it byte-identically, since the resolution was correct given
the package.json files rather than stale.

These four declarations are TEMPORARY, like the overrides they support, and come
out with them when @Ag-ui publishes the rename.

Verified: @copilotkit/core, react-core and sdk-js typecheck; react-core 1424
tests and vue 1071 tests pass.
…review bump

Removes SubagentRegistry, useSubagent and their core wiring from the
mme/subagents branch, leaving only the dependency work: the @ag-ui/* overrides
pinned to pkg.pr.new previews of ag-ui-protocol/ag-ui#2350, whose bundled
@ag-ui/client carries the subagent event types (SUBAGENT_STARTED/FINISHED/
ERROR), the AgentSubscriber dispatch and subagentRunId message attribution.

The AG-UI dojo demo now consumes those subscriber callbacks directly and no
longer imports useSubagent, so this minimal bump is all the dojo needs from
CopilotKit. The registry/hook (untested, no other consumer) can return as its
own PR if user demand for a first-class hook materializes.
@mme

mme commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Not needed after all: #6756 already bumps the CopilotKit packages to the released @ag-ui 0.0.59 — the first release carrying the subagent surface — so there is nothing left for a pkg.pr.new-override vehicle to provide. This PR was built on the stale #5873 base (react-core 1.62.2) purely to keep the AG-UI dojo's preview pins alive after dropping the hook; the dojo now pins #6756's previews instead (react-core 1.69.3, commit 71d9731) and its deepagents e2e passes against them. Once #6756 merges and a release ships, the dojo moves to released versions and no preview pin remains (PNI-275).

@mme mme closed this Aug 28, 2026
@mme
mme deleted the mme/bump-ag-ui-subagent-events branch August 28, 2026 14:41
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.

2 participants