Repository navigation
fix(react-core): render every v1 tool call - #6682
Merged
BenTaylorDev merged 1 commit intoAug 30, 2026
Merged
BenTaylorDev merged 1 commit into
BenTaylorDev merged 1 commit into
Conversation
Totoro-qaq
marked this pull request as ready for review
August 25, 2026 08:54
Totoro-qaq
requested review from
jpr5,
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
August 25, 2026 08:54
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-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: |
BenTaylorDev
approved these changes
Aug 30, 2026
This was referenced Sep 4, 2026
🐛 Bug: Issue: renderAndWaitForResponse doesn't reliably render intermediate "inProgress" state
#2927
Closed
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 -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
nullrender results and returnsnullwhen no tool has a renderer.Keeping the fragment behind the existing lazy-renderer callback preserves the exported
useLazyToolRendererreturn 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-typespnpm 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.tsxChecklist