Skip to content

fix(react-core): render every v1 tool call - #6682

Merged
BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
Totoro-qaq:codex/fix-multiple-v1-tool-renderers
Aug 30, 2026
Merged

BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
Totoro-qaq:codex/fix-multiple-v1-tool-renderers

Conversation

@Totoro-qaq

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the v1 compatibility render path so an assistant message can render every tool call instead of only toolCalls[0].

The returned lazy renderer now:

  • matches each tool call with its corresponding tool result;
  • renders all registered tool-call renderers in one fragment;
  • removes null render results and returns null when no tool has a renderer.

Keeping the fragment behind the existing lazy-renderer callback preserves the exported useLazyToolRenderer return signature. Filtering before returning also avoids attaching empty generative UI, so caller-provided subcomponents are not suppressed when no renderer is registered.

Regression tests cover multiple tool calls, per-call result matching, the all-unhandled case, and a mixed handled/unhandled message.

Related PRs and Issues

Verification

  • pnpm nx run @copilotkit/react-core:test (133 files, 1,530 Vitest tests plus 47 script tests)
  • pnpm nx run @copilotkit/react-core:check-types
  • pnpm exec oxfmt --check packages/react-core/src/v1-deprecated/hooks/use-lazy-tool-renderer.tsx packages/react-core/src/v1-deprecated/hooks/__tests__/use-lazy-tool-renderer.test.tsx

Checklist

  • I have read the Contribution Guide
  • Documentation is unchanged because this restores existing v1 behavior without changing the public API
  • "Allow edits by maintainers" is checked

@Totoro-qaq
Totoro-qaq marked this pull request as ready for review August 25, 2026 08:54
@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@6682

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@6682

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@6682

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@6682

@copilotkit/channels-core

pnpm add https://pkg.pr.new/@copilotkit/channels-core@6682

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@6682

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@6682

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@6682

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@6682

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@6682

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@6682

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@6682

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@6682

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@6682

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@6682

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@6682

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@6682

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@6682

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@6682

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@6682

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@6682

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@6682

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@6682

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@6682

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@6682

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@6682

commit: 0b85f08

@BenTaylorDev
BenTaylorDev merged commit 69441cc into CopilotKit:main Aug 30, 2026
39 checks passed
BenTaylorDev added a commit that referenced this pull request Sep 21, 2026
…ldcard handlers (#7315)

Two frontend human-in-the-loop defects that are still live on `main`.
One commit each, so either can be reviewed or reverted alone.

This replaces the two still-live halves of #6527, which I am closing.
Its other two halves have since landed through other PRs — the parallel
v1 tool rendering fix through #6682 (and its file has since moved under
`v1-deprecated/`), and the wildcard HITL name fix through `b17c8556be` —
so that branch is now two dead commits, one conflicting file path, and
these two fixes. Rebasing it was not worth it.

### OSS-803 — Vue `humanInTheLoop` provider prop resolved immediately

The Vue provider's `humanInTheLoop` **prop** path registered a handler
that warned and resolved `undefined` right away, so the HITL UI flashed
and disappeared instead of waiting for the user, and it registered
`tool.render` unwrapped so the renderer never received a working
`respond`.

React's provider fixed exactly this separately
(`packages/react-core/src/v2/providers/CopilotKitProvider.tsx`,
`pendingHumanInTheLoopRef`). This brings Vue to parity with it and with
Vue's own `useHumanInTheLoop` composable:

- the tool-call promise stays pending until `respond` is called
- `respond` is live only while status is `Executing`
- an aborted run **rejects** with `Human-in-the-loop interaction
aborted`, so core records an explicit error tool result rather than
silently resolving empty (#5554)
- pending interactions are keyed by tool call id, so parallel interrupts
on the same tool stay independent
- a wildcard (`name: "*"`) registration keeps the invoked tool's name
- the wrapper passes `agentId`, which `VueHumanInTheLoopRenderProps`
declares and the composable already supplies (this one is mine, not in
#6527)

The abort bullet depends on a `signal` that core does not always supply
— hence the second commit.

### `packages/core` — wildcard tool handlers never received the abort
signal

The named-tool path calls handlers with `signal:
this._runAbortController?.signal` (`run-handler.ts:918`), but
`executeWildcardTool` passed only `{ toolCall, agent }`
(`run-handler.ts:1101`). A wildcard handler that waits on something
therefore could never observe an abort, so a HITL tool registered as
`"*"` stayed pending forever when the run was stopped — in React's
`useHumanInTheLoop` as much as in the Vue provider path above.

The fix adds that one argument. It is additive: handlers that ignore the
signal are unaffected, and `signal` was previously `undefined` for this
path. `FrontendToolHandlerContext.signal` is already optional and
already documented (`packages/core/src/types.ts:39`).

## Testing

Every fix has a test that fails without it. Each negative control was
run by reverting **only** the source file on this branch and re-running
the same tests.

**OSS-803** — 7 unit tests in `CopilotKitProvider.test.ts`
(pending-until-respond, `respond` only while executing, abort rejects,
already-aborted rejects, parallel interrupts independent, wildcard name,
`agentId` forwarded), plus 2 **mounted** end-to-end tests in
`CopilotKitProvider.hitl.e2e.test.ts`. Two existing tests asserted the
old placeholder behavior (`resolves undefined` + the warning) or
compared `render` by identity, and were updated: the renderer is now a
wrapper, so they assert it *delegates* to the user's component.

The unit tests drive the registered renderer directly with a synthesized
handler context, which cannot catch a mismatch between the key the
handler stores under and the tool call id the real pipeline supplies.
The e2e file closes that: it mounts `CopilotChat →
CopilotChatToolCallsView →` the provider's wrapper, so the wrapper runs
as a real Vue functional component and the key comes from core's own
tool call id.

With the fix:

```
 ✓ src/v2/providers/__tests__/CopilotKitProvider.wildcard.test.ts (5 tests)
 ✓ src/v2/providers/__tests__/CopilotKitProvider.test.ts (33 tests)
 ✓ src/v2/providers/__tests__/CopilotKitProvider.hitl.e2e.test.ts (2 tests)

 Test Files  3 passed (3)
      Tests  40 passed (40)
```

With `CopilotKitProvider.vue` alone reverted to `origin/main`, 11 fail —
including both e2e tests, which never reach `Executing` so no approve
button is ever rendered:

```
 × supports wildcard in humanInTheLoop
 × processes humanInTheLoop tools and creates handlers
 × keeps the tool call pending until respond is called
 × exposes respond only while the tool is executing
 × rejects the pending tool call when the run is aborted
 × rejects immediately when the run was already aborted
 × keeps parallel interrupts on the same tool independent
 × passes the actual invoked tool name to a wildcard HITL renderer
 × combines render components from all sources
 × waits for the user and completes with the response
 × passes the invoked tool name to a wildcard registration

 Test Files  3 failed (3)
      Tests  11 failed | 29 passed (40)
```

The `agentId` line mutation-checks on its own: deleting only `agentId:
tool.agentId` from the wrapper fails exactly one test, `passes agentId
through to the HITL renderer`, and nothing else.

**core wildcard signal** — 2 new tests in
`core-abort-during-tool.test.ts`, mirroring the named-tool pair already
there: one asserts a wildcard handler receives an `AbortSignal`, the
other that `stopAgent()` during wildcard execution aborts it. With the
fix, `6 passed (6)`. Reverting only the changed line in `run-handler.ts`
fails both while the four existing tests stay green:

```
 ✓ should NOT restart the run when stopAgent is called during tool execution
 ✓ should pass an AbortSignal to the tool handler context
 ✓ should abort the signal when stopAgent is called during tool execution
 × should pass an AbortSignal to a wildcard tool handler context
   → expected undefined to be an instance of AbortSignal
 × should abort the signal when stopAgent is called during wildcard tool execution
   → expected undefined to be true
 ✓ should NOT restart the run when agent.abortRun() is called directly during tool execution

 Test Files  1 failed (1)
      Tests  2 failed | 4 passed (6)
```

### Repo-wide checks

| Check | Result |
| --- | --- |
| `@copilotkit/vue` full suite | `106 passed (106)` files, `1135 passed
(1135)` tests |
| `@copilotkit/vue` `vue-tsc --noEmit` | clean |
| `@copilotkit/core` full suite (uncached) | `76 passed (76)` files,
`894 passed (894)` tests |
| `@copilotkit/core` `tsc --noEmit` | clean |
| `oxfmt --check` on all 6 changed files | `All matched files use the
correct format.` |
| `eslint` on changed Vue files | 2 errors, byte-identical to
`origin/main` on the same file (both unused-import false positives, same
two symbols) — no new lint errors |

The stale-`@copilotkit/shared` build artifact that forced a
`--no-verify` commit and 20 `core-inspector-metadata` timeouts on #6527
is not present here: this worktree was set up with a full `pnpm
install`, so the core suite is genuinely green.

## Not in this PR

- The Vue `useHumanInTheLoop` **composable** has the same wildcard
`name` clobber that React's hook fixed, and no abort handling at all.
Separate from the prop path this PR fixes.
- OSS-805 (passive client disconnect does not abort an in-flight run).
Abort-on-disconnect is not unconditionally correct — disconnect-tolerant
runs are deliberate for reconnect-to-in-flight-thread and
durable/background runs — so the per-runner semantics need deciding
before `request.signal` gets wired up.

Fixes OSS-803

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Human-in-the-loop tools remain pending until users respond through the
rendered interface.
- Wildcard tool handlers and renderers receive the actual invoked tool
name.
  - Multiple simultaneous tool interactions are tracked independently.

- **Bug Fixes**
- Stopping an agent now properly aborts pending human-in-the-loop
interactions.
- Pending interactions no longer remain unresolved when an abort occurs.
- Response controls are available only while a tool is actively
executing.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

🐛 Bug: 1.50 no longer renders AG-UI tool events correctly

2 participants