mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
3341007c19
## Summary Fixes the remote-agent HITL case where a frontend tool is skipped because the backend returns the placeholder result `Forwarded to client`. The recovery is now marker-based. `processAgentResult` only removes an existing tool result when the content normalizes to that exact placeholder and there is an executable frontend handler on the current path. Every other backend result stays authoritative and blocks frontend re-execution. ## Implementation - `packages/core/src/core/run-handler.ts` keeps the current `executeFrontendTools` and follow-up flow, then replaces the old existence-only check with exact placeholder detection at https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/core/run-handler.ts#L484-L599 - the placeholder is removed from both `newMessages` and `agent.messages` before the existing specific or wildcard execution path inserts the real result - `.changeset/fix-frontend-tool-placeholder.md` is dropped because current `main` no longer carries a `.changeset` tree ## Regression coverage - exact placeholder replacement for a named frontend tool: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L22-L51 - placeholder passthrough when the tool has no handler: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L53-L82 - genuine backend-result preservation for a named frontend tool: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L85-L109 - existing edge-case guard for a non-placeholder result: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-edge-cases.test.ts#L23-L54 - existing wildcard execution still works with no pre-existing result: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L111-L154 - wildcard placeholder replacement also stays on the exact marker path: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L156-L187 - the recursive follow-up starts with the assistant tool call intact and exactly one real tool message for the same `toolCallId`: https://github.com/CopilotKit/CopilotKit/blob/7449f6d790dbe80ab8e0950f66b04a9bf4acde2c/packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts#L189-L250 Closes #3442. ## Validation - [x] `pnpm exec oxfmt --check packages/core/src/core/run-handler.ts packages/core/src/__tests__/core-edge-cases.test.ts packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts` - [x] `pnpm exec oxlint packages/core/src/core/run-handler.ts packages/core/src/__tests__/core-edge-cases.test.ts packages/core/src/__tests__/core-frontend-tool-placeholder.test.ts` - [x] `pnpm -C packages/shared exec tsdown` - [x] `pnpm -C packages/core exec tsdown` - [x] `pnpm -C packages/core exec vitest run src/__tests__/core-frontend-tool-placeholder.test.ts src/__tests__/core-edge-cases.test.ts` 17/17 - [x] `pnpm -C packages/core exec vitest run` 54 files, 590 tests - [ ] CI green on the rebased head