Repository navigation
Conversation
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]>
📣 Social Copy GeneratorGenerate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/bot
@copilotkit/bot-discord
@copilotkit/bot-slack
@copilotkit/bot-teams
@copilotkit/bot-telegram
@copilotkit/bot-ui
@copilotkit/bot-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
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.
CopilotKit adopted the rename (CopilotKit/CopilotKit#5873, commit c2fca03), so `useSubagent` now takes `subagentRunId`. The temporary `{ subagentId: subagentRunId }` mapping is gone and the call site is plain shorthand again. With this, NO occurrence of the old name remains anywhere in this repo. Repins the six @CopilotKit previews from the moving `@5873` tag to commit `@c2fca03`, which is also a fix rather than a detail. The tag tracks the PR's latest build, and pnpm caches a tarball against the URL STRING -- so once the PR was rebuilt, the tag-pinned URL kept serving the stale cached build even through `pnpm install --force` and after deleting the store directories. Confirmed directly: the URL served a tarball with 86 occurrences of subagentRunId while the installed copy still had 86 of subagentId. A commit-pinned URL is a new string, so it always resolves fresh. Bump the sha to take a newer CopilotKit build. The same trap applies to the @Ag-ui pins on the CopilotKit side, which still use the moving `@2350` tag; worth commit-pinning there too before that PR is rebuilt. Verified: `demo-viewer:build` compiles against the renamed CopilotKit, and the dojo resolves the commit-pinned preview (86 subagentRunId, 0 subagentId). files.json regenerated from source.
CopilotKit adopted the rename (CopilotKit/CopilotKit#5873, commit c2fca03), so `useSubagent` now takes `subagentRunId`. The temporary `{ subagentId: subagentRunId }` mapping is gone and the call site is plain shorthand again. With this, NO occurrence of the old name remains anywhere in this repo. Repins the six @CopilotKit previews from the moving `@5873` tag to commit `@c2fca03`, which is also a fix rather than a detail. The tag tracks the PR's latest build, and pnpm caches a tarball against the URL STRING -- so once the PR was rebuilt, the tag-pinned URL kept serving the stale cached build even through `pnpm install --force` and after deleting the store directories. Confirmed directly: the URL served a tarball with 86 occurrences of subagentRunId while the installed copy still had 86 of subagentId. A commit-pinned URL is a new string, so it always resolves fresh. Bump the sha to take a newer CopilotKit build. The same trap applies to the @Ag-ui pins on the CopilotKit side, which still use the moving `@2350` tag; worth commit-pinning there too before that PR is rebuilt. Verified: `demo-viewer:build` compiles against the renamed CopilotKit, and the dojo resolves the commit-pinned preview (86 subagentRunId, 0 subagentId). files.json regenerated from source.
CopilotKit adopted the rename (CopilotKit/CopilotKit#5873, commit c2fca03), so `useSubagent` now takes `subagentRunId`. The temporary `{ subagentId: subagentRunId }` mapping is gone and the call site is plain shorthand again. With this, NO occurrence of the old name remains anywhere in this repo. Repins the six @CopilotKit previews from the moving `@5873` tag to commit `@c2fca03`, which is also a fix rather than a detail. The tag tracks the PR's latest build, and pnpm caches a tarball against the URL STRING -- so once the PR was rebuilt, the tag-pinned URL kept serving the stale cached build even through `pnpm install --force` and after deleting the store directories. Confirmed directly: the URL served a tarball with 86 occurrences of subagentRunId while the installed copy still had 86 of subagentId. A commit-pinned URL is a new string, so it always resolves fresh. Bump the sha to take a newer CopilotKit build. The same trap applies to the @Ag-ui pins on the CopilotKit side, which still use the moving `@2350` tag; worth commit-pinning there too before that PR is rebuilt. Verified: `demo-viewer:build` compiles against the renamed CopilotKit, and the dojo resolves the commit-pinned preview (86 subagentRunId, 0 subagentId). files.json regenerated from source.
CopilotKit adopted the rename (CopilotKit/CopilotKit#5873, commit c2fca03), so `useSubagent` now takes `subagentRunId`. The temporary `{ subagentId: subagentRunId }` mapping is gone and the call site is plain shorthand again. With this, NO occurrence of the old name remains anywhere in this repo. Repins the six @CopilotKit previews from the moving `@5873` tag to commit `@c2fca03`, which is also a fix rather than a detail. The tag tracks the PR's latest build, and pnpm caches a tarball against the URL STRING -- so once the PR was rebuilt, the tag-pinned URL kept serving the stale cached build even through `pnpm install --force` and after deleting the store directories. Confirmed directly: the URL served a tarball with 86 occurrences of subagentRunId while the installed copy still had 86 of subagentId. A commit-pinned URL is a new string, so it always resolves fresh. Bump the sha to take a newer CopilotKit build. The same trap applies to the @Ag-ui pins on the CopilotKit side, which still use the moving `@2350` tag; worth commit-pinning there too before that PR is rebuilt. Verified: `demo-viewer:build` compiles against the renamed CopilotKit, and the dojo resolves the commit-pinned preview (86 subagentRunId, 0 subagentId). files.json regenerated from source.
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.
A demo page that renders each subagent's output as its own collapsible,
reasoning-style group: name and description from useSubagent, tool-call cards
inside the owning group, a checkmark when the subagent finishes, and an interrupt
handled inside a subagent.
Grouping is driven by `subagentRunId` on the messages via renderCustomMessages,
which is the consumer-side proof that attribution survives the whole path --
LangGraph's derived namespaces, the protocol events, the client's apply step, and
CopilotKit's rendering. Scoped to the Python-backed integrations, since the agent
is a LangGraph graph.
`useSubagent({ subagentRunId })` is plain shorthand: CopilotKit adopted the same
field name (CopilotKit/CopilotKit#5873), so no mapping is needed at the boundary.
If it ever needs an explicit mapping again, the two names have diverged.
|
Closing in favor of #6757, which is this branch minus the registry and hook. The AG-UI dojo demo (ag-ui-protocol/ag-ui#2351) was What survives: the |
Bumps the published packages from `@ag-ui/*` **0.0.57 → 0.0.59** — 27 declarations across 18 packages in `packages/**`. 0.0.59 is the first AG-UI release carrying the subagent protocol surface (`SUBAGENT_STARTED` / `SUBAGENT_FINISHED` / `SUBAGENT_ERROR`, `subagentRunId`) together with the null-omission cleanup, so it is the dependency the subagent work needs. Landing the bump on its own keeps that review separate from the feature work in #5873, which currently pins `pkg.pr.new` previews of the (now released) ag-ui PR. ### Scope `packages/**` only — the shipped libraries, which were uniformly on 0.0.57. Examples and showcases are deliberately untouched: they sit on a spread of pins from 0.0.40 to 0.0.58 and bumping them would bury this diff. `@ag-ui/langgraph` (0.0.42) and the mcp middlewares are separate packages and also left alone. ### One behavioural change worth reviewing `channels-core` ships `sanitizeAgentEventStream` because `@ag-ui/client` used to **reject** a `TOOL_CALL_START` carrying `parentMessageId: null` — the shape `@ag-ui/langgraph` emits for the tool call that triggers an interrupt. As of 0.0.59 the client **accepts** that null and treats it as absent (it is one of a small set of receive tolerances kept for producers that still emit it). That invalidates the two tests asserting the run dies *without* the sanitizer: - `aborts that same run when the sanitizer is not applied` → now `survives that same run without the sanitizer, since 0.0.59 tolerates the null`. It asserts the tool call actually arrives, not merely that nothing throws, so it cannot pass vacuously. - `lets the run abort when sanitizing is disabled` → `no longer aborts the turn when sanitizing is disabled`. **The sanitizer itself is untouched** and its coercion tests are unchanged — it still rewrites the byte on the wire. It is simply no longer the thing keeping such a run alive. Whether to keep it as belt-and-braces or retire it is a follow-up decision, not part of this bump. ### Verification - All `packages/**` build against 0.0.59. - `check-types` clean for `core`, `shared`, `react-core`, `runtime`. - Tests pass: core 786, shared 304, runtime 2084, react-core 1514, channels-core 267. - The full `test,publint,attw` pre-commit gate passes across the 26 affected projects. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of tool calls with missing parent message identifiers, preventing unnecessary turn failures—even when event sanitization is disabled. * Ensured Angular validation uses the matching AG UI client version, improving compatibility during package verification. * **Chores** * Updated AG UI client, core, and encoder packages to version 0.0.59 across supported integrations and runtimes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Draft. Adds subagent lifecycle tracking to CopilotKit core and a
useSubagenthook.SubagentRegistrydelegate onCopilotKitCore— tracksSUBAGENT_STARTED/FINISHED/ERRORper owning agent (modeled onSuggestionEngine; owns its own per-agentagent.subscribelikeStateManager). Exposed viagetSubagents(agentId)+ anonSubagentsChangedsubscription.useSubagent({ subagentRunId | subagentName, agentId? })(react-core v2) — resolves a message'ssubagentRunIdto a friendlyname,description, and runningstatus. Warns once (dev) when asubagentNameis ambiguous.Field name:
subagentRunId(renamed fromsubagentId)AG-UI renamed the 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.
Both sides of this package moved:
SubagentRegistryconsumesevent.subagentRunId. This part had to move: the events are typed asSubagentStartedEventetc. from@ag-ui/core, so against the renamed protocol the old field is simply absent and the registry would silently stay empty — every lookup returningundefined, with no error.useSubagent({ subagentRunId })andSubagentState.subagentRunId. This is a breaking change to the hook, taken now because it has never shipped — it exists only on this branch, so there is no released consumer to migrate and no alias to maintain. It also makes the API self-consistent: the hook already distinguishessubagentRunId(exact, one invocation) fromsubagentName(the declaredsubagent_type, not unique), which is precisely the split the old name blurred.Dependency: consumed via pkg.pr.new (no @Ag-ui release needed)
Requires the AG-UI subagent event schemas +
AgentSubscribercallbacks. The@ag-ui/*overrides point at the pkg.pr.new preview of ag-ui-protocol/ag-ui#2350 (https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/*@2350), which carries the rename — verified before pinning: that build's@ag-ui/corehas 584 occurrences ofsubagentRunIdand zero ofsubagentId.All five overrides move together on purpose.
@ag-ui/langgraphdepends on@ag-ui/client, so leaving it on the old canary whileclientmoves would resolve two incompatible copies of the same package.Reviewer notes:
.npmrckeepsblock-exotic-subdeps=true. An earlier revision of this description said it was set tofalse; that is no longer the case and the guard does not need weakening.pnpm install --frozen-lockfilesucceeds against the committed lockfile with the guard on; only a fresh re-resolution of the five@ag-uipackages needsnpm_config_block_exotic_subdeps=falsefor that single run, because@ag-ui/encoderdeclares@ag-ui/protoand that now resolves via url.@2350tag tracks that PR's latest build — only the committed lockfile holds this to one specific artifact. Swap for a released version once ag-ui#2350 merges and ships.mainand will need a rebase before merge.Verified:
@copilotkit/coreand@copilotkit/react-coretypecheck against the renamed protocol, and react-core's 1424 tests pass. The typecheck is load-bearing rather than 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.🤖 Generated with Claude Code