Skip to content

fix(react-core): make useCoAgent's start, run and stop work, through the v2 core - #7610

Merged
BenTaylorDev merged 5 commits into
mainfrom
ben1/3132-usecoagent-bind
Oct 5, 2026
Merged

BenTaylorDev merged 5 commits into
mainfrom
ben1/3132-usecoagent-bind

Conversation

@BenTaylorDev

@BenTaylorDev BenTaylorDev commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Refs #3132. This fixes the half of that issue that reproduces on main. The other half (state not syncing with an ADK backend) did not reproduce, so the issue stays open.

Problem

v1 useCoAgent returned start, run and stop as bare references to agent.runAgent and agent.abortRun. There were two defects.

1. The calls crashed. Both are prototype methods that read this. The documented usage destructures them, const { start } = useCoAgent(...), and a destructured call throws:

TypeError: Cannot set properties of undefined (setting 'isRunning')

Calling one as a method of the result (coagent.start()) fails too, because this is then the result object:

TypeError: this.prepareRunAgentInput is not a function

On an HttpAgent (and the agents built on it), stop() threw Cannot read properties of undefined (reading 'abortController').

2. Behind the crash, the run skipped the v2 core. agent.runAgent() sends the request but does none of the work that copilotkit.runAgent({ agent }) does (see programmatic-control.mdx, "copilotkit.runAgent() vs agent.runAgent()"):

  • The config that useCoAgent sets with copilotkit.setProperties never reached the agent.
  • Registered frontend tools and readable context were not sent.
  • A frontend tool call that the agent made never ran.

The v1 chat path (use-copilot-chat_internal.ts) already goes through the core. Nobody hit this second defect, because the first one crashed every call first.

Change

packages/react-core/src/v1-deprecated/hooks/use-coagent.ts:

  • start and run call copilotkit.runAgent({ agent, forwardedProps, runId }). They take forwardedProps and runId from the first argument. The core builds the tools and context itself.
  • stop calls copilotkit.stopAgent({ agent }), as the v2 chat does. That also cancels in-flight tool handlers and the follow-up run, which a bare abortRun() did not.
  • All three are useCallback wrappers keyed on agent and copilotkit. They keep a stable identity across state changes, as the bare prototype methods did, so app code such as useEffect(..., [start]) behaves the same.
  • The public type of run ((...args: any[]) => Promise<any>) is unchanged. Its JSDoc now says which fields are honored.

This is a v1 bug fix. It adds no API.

Testing

use-coagent-methods.test.ts drives the hook with a real AbstractAgent subclass and a real CopilotKitCore. The older tests mock runAgent with vi.fn(), which never reads this and never goes through a core, so they could not see either defect.

The 8 tests:

  • start detached, run detached, and start as a method of the result each run the agent.
  • run sends the configured properties, a registered frontend tool and readable context, plus its own forwardedProps.
  • A frontend tool call that the agent makes executes, and its handler receives the parsed arguments.
  • run forwards runId and returns the run's result.
  • start, run and stop keep their identity across a state change. The test also asserts that the memo did recompute, so the check is not vacuous.
  • stop calls copilotkit.stopAgent({ agent }), and the agent aborts.

Against main's source:

Tests  7 failed | 1 passed (8)

Only the stability test passes there, because the bare methods were stable.

Against the previous commit of this PR (direct agent.runAgent): the config/tools/context test and the tool-execution test fail:

Tests  2 failed | 6 passed (8)

Mutation checks:

  • A stop that calls a bare agent.abortRun() fails the stop test (1 failed | 7 passed).
  • An earlier run that dropped its arguments and its returned promise failed the argument test.
  • Building the wrappers inside the useMemo failed the stability test.

On this branch:

Tests  8 passed (8)

Gates:

  • vitest run in packages/react-core (full suite): 164 files, 1803 tests, all pass.
  • nx run @copilotkit/react-core:check-types --skip-nx-cache: pass.
  • oxlint on the changed files: 0 errors. The hook file has 13 older warnings (main has 14), and none is on a changed line.
  • oxfmt: clean.
  • The pre-commit hook (test, publint, attw on affected projects): pass.

Not done: a live check in a running v1 app. The tests use the real agent class and the real core, so they cover the binding and the core path that an app would hit.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Agent runs now include configured properties, frontend tools, and readable context, and support forwarding additional properties and run IDs. Run results are returned to callers, while failed runs resolve with an empty result.
    • Stopping an agent now correctly aborts its run through the core.
  • Documentation
    • Clarified how agent runs and failures are handled.

useCoAgent returned agent.runAgent and agent.abortRun as bare references.
Both are prototype methods that read `this`, so calling them detached, as
`const { start } = useCoAgent(...)` does, threw "Cannot set properties of
undefined (setting 'isRunning')". On an HttpAgent, stop threw on
`abortController`. They are now wrapped in arrow functions.

The new test uses a real AbstractAgent subclass. The existing tests mock
runAgent with vi.fn(), which never reads `this`, so they could not see it.

Refs #3132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: CopilotKit/CopilotKit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3576f481-92cb-40b3-99ec-03cc0cd53e55
📥 Commits

Reviewing files that changed from the base of the PR and between e745116 and dda80b7.

📒 Files selected for processing (3)
  • packages/react-core/src/v1-deprecated/hooks/__tests__/use-coagent-methods.test.ts
  • packages/react-core/src/v1-deprecated/hooks/use-coagent.ts
  • showcase/shell-docs/src/content/reference/v1/hooks/useCoAgent.mdx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The deprecated useCoAgent hook now routes run and stop calls through CopilotKitCore. The run callback accepts optional forwardedProps and runId. New tests cover run inputs, frontend tool calls, callback stability, and stop behavior.

Changes

Co-agent method routing

Layer / File(s) Summary
Core-backed methods and behavior validation
packages/react-core/src/v1-deprecated/hooks/use-coagent.ts, packages/react-core/src/v1-deprecated/hooks/__tests__/use-coagent-methods.test.ts, showcase/shell-docs/src/content/reference/v1/hooks/useCoAgent.mdx
useCoAgent routes run and stop calls through the core. Its documentation describes the run parameters and execution path. Tests check detached and result-bound calls, run inputs, frontend tool handling, returned results, callback stability, and stop behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to dda80

The co-agent methods now use core execution and cancellation, with tests covering the changed behavior. No concrete issue remains that should delay merging.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to dda80

Run and stop now use the established tool-execution path and retain agent-specific data filtering. However, stopping one agent can interrupt another agent’s tool or approval work when they share the same application instance.

Retained concerns

  • Medium · reliability · inferred: The newly core-backed, agent-specific stop operation reaches a shared abort controller regardless of the selected agent. With agent B executing a frontend tool, calling agent A’s stop can abort B’s handler signal, suppress B’s remaining tools or follow-up, and close its pending approval interaction, even if A has no active run. This breaks agent-level cancellation ownership and failure containment. The shared-controller behavior already existed in core, but this PR makes it reachable through the compatibility hook’s stop operation.
Security review details

Security Blast Radius

  • inferred — The supported cancellation-interference scope is other agents sharing the same core instance. The selected agent parameter restricts transport abort and replay cleanup, but does not restrict the shared frontend-tool abort controller.

Security Findings and Attack Paths

  • inferred — An application caller holding agent A’s hook result can invoke stop while agent B awaits a tool or approval response. The call aborts B’s shared processing signal, allowing interference beyond the selected agent. This establishes a failure-containment path, not a demonstrated unauthenticated remote attack or privilege escalation.

Trust Boundaries and Controls

  • observed — The new caller uses existing agent-identity controls: advertised tools exclude unavailable, disabled, and other-agent tools; specific-tool execution checks agent identity again; readable context excludes entries scoped to other agents. Unscoped registrations remain shared by design.

Hardening Proposals

  • proposed — Associate cancellation controllers and continuation ownership with the selected agent and logical run, preserving that identity across recursive follow-ups. Stopping an idle or unrelated agent should leave another agent’s handlers and approval interactions untouched.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: routing the v1 useCoAgent methods through the v2 core.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
@copilotkit/a2ui-renderer

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

@copilotkit/agentcore-runner

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

@copilotkit/angular

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

@copilotkit/channels

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

@copilotkit/channels-core

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

@copilotkit/channels-discord

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

@copilotkit/channels-intelligence

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

@copilotkit/channels-slack

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

@copilotkit/channels-teams

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

@copilotkit/channels-telegram

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

@copilotkit/channels-ui

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

@copilotkit/channels-whatsapp

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

@copilotkit/core

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

@copilotkit/intelligence-langgraph

pnpm add https://pkg.pr.new/@copilotkit/intelligence-langgraph@7610

@copilotkit/intelligence-mastra

pnpm add https://pkg.pr.new/@copilotkit/intelligence-mastra@7610

@copilotkit/learning

pnpm add https://pkg.pr.new/@copilotkit/learning@7610

@copilotkit/mcp-apps-renderer

pnpm add https://pkg.pr.new/@copilotkit/mcp-apps-renderer@7610

@copilotkit/react-core

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

@copilotkit/react-native

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

@copilotkit/react-textarea

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

@copilotkit/react-ui

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

@copilotkit/runtime

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

@copilotkit/runtime-client-gql

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

@copilotkit/sdk-js

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

@copilotkit/shared

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

@copilotkit/sqlite-runner

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

@copilotkit/voice

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

@copilotkit/vue

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

@copilotkit/web-components

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

@copilotkit/web-inspector

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

commit: dda80b7

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Size Change: +228 B (+0.01%)

Total Size: 1.77 MB

📦 View Changed
Filename Size Change
packages/react-core/dist/index.cjs 17.7 kB +92 B (+0.52%)
packages/react-core/dist/index.mjs 17.6 kB +63 B (+0.36%)
packages/react-core/dist/index.umd.js 68.4 kB +73 B (+0.11%)
ℹ️ View Unchanged
Filename Size
packages/a2ui-renderer/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/a2ui-renderer/dist/a2ui-types.cjs 472 B
packages/a2ui-renderer/dist/a2ui-types.mjs 469 B
packages/a2ui-renderer/dist/index.cjs 959 B
packages/a2ui-renderer/dist/index.mjs 637 B
packages/a2ui-renderer/dist/index.umd.js 13.4 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.cjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/A2uiSurface.mjs 1.46 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.cjs 1.57 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/adapter.mjs 1.5 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.cjs 904 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/AudioPlayer.mjs 492 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.cjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Button.mjs 603 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.cjs 829 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Card.mjs 419 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/CheckBox.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.cjs 799 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChildList.mjs 737 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.cjs 1.64 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/ChoicePicker.mjs 1.57 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.cjs 856 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Column.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.cjs 1.12 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/DateTimeInput.mjs 1.05 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.cjs 842 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Divider.mjs 432 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.cjs 877 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Icon.mjs 469 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.cjs 995 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Image.mjs 587 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.cjs 920 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/List.mjs 508 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.cjs 1.2 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Modal.mjs 1.14 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.cjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Row.mjs 801 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.cjs 1.06 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Slider.mjs 984 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.cjs 1.1 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Tabs.mjs 1.04 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.cjs 903 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Text.mjs 489 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/TextField.mjs 1.14 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.cjs 788 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/components/Video.mjs 378 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.cjs 928 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/index.mjs 855 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.cjs 579 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/basic/utils.mjs 556 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.cjs 989 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Button.mjs 584 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.cjs 800 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/ChildList.mjs 735 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.cjs 1.08 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Column.mjs 1.02 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.cjs 1.07 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Row.mjs 1.01 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.cjs 894 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/Text.mjs 839 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.cjs 1.21 kB
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/components/TextField.mjs 802 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.cjs 849 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/catalog/minimal/index.mjs 804 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.cjs 310 B
packages/a2ui-renderer/dist/react-renderer/a2ui-react/index.mjs 325 B
packages/a2ui-renderer/dist/react-renderer/catalog-utils.cjs 1.59 kB
packages/a2ui-renderer/dist/react-renderer/catalog-utils.mjs 1.52 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.cjs 1.5 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIProvider.mjs 1.42 kB
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.cjs 728 B
packages/a2ui-renderer/dist/react-renderer/core/A2UIRenderer.mjs 671 B
packages/a2ui-renderer/dist/react-renderer/create-catalog.cjs 1.35 kB
packages/a2ui-renderer/dist/react-renderer/create-catalog.mjs 1.28 kB
packages/a2ui-renderer/dist/react-renderer/filter-catalog.cjs 622 B
packages/a2ui-renderer/dist/react-renderer/filter-catalog.mjs 569 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.cjs 316 B
packages/a2ui-renderer/dist/react-renderer/hooks/useA2UI.mjs 309 B
packages/a2ui-renderer/dist/react-renderer/index.cjs 409 B
packages/a2ui-renderer/dist/react-renderer/index.mjs 568 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.cjs 236 B
packages/a2ui-renderer/dist/react-renderer/lib/utils.mjs 188 B
packages/a2ui-renderer/dist/react-renderer/styles/index.cjs 239 B
packages/a2ui-renderer/dist/react-renderer/styles/index.mjs 231 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.cjs 436 B
packages/a2ui-renderer/dist/react-renderer/theme/ThemeContext.mjs 381 B
packages/core/dist/index.cjs 79.7 kB
packages/core/dist/index.mjs 79.2 kB
packages/core/dist/index.umd.js 85.4 kB
packages/mcp-apps-renderer/dist/activity.cjs 259 B
packages/mcp-apps-renderer/dist/activity.mjs 170 B
packages/mcp-apps-renderer/dist/activity.umd.js 2.24 kB
packages/mcp-apps-renderer/dist/constants.cjs 714 B
packages/mcp-apps-renderer/dist/constants.mjs 712 B
packages/mcp-apps-renderer/dist/content-schema.cjs 768 B
packages/mcp-apps-renderer/dist/content-schema.mjs 765 B
packages/mcp-apps-renderer/dist/follow-up.cjs 796 B
packages/mcp-apps-renderer/dist/follow-up.mjs 794 B
packages/mcp-apps-renderer/dist/index.mjs 354 B
packages/mcp-apps-renderer/dist/request-queue.mjs 2.39 kB
packages/mcp-apps-renderer/dist/sandbox.mjs 1.14 kB
packages/mcp-apps-renderer/dist/session.mjs 6.81 kB
packages/react-core/dist/copilotkit-CFPkj9B9.cjs 120 kB
packages/react-core/dist/copilotkit-CP9qPAqV.mjs 123 kB
packages/react-core/dist/v2/context.cjs 1.58 kB
packages/react-core/dist/v2/context.mjs 1.5 kB
packages/react-core/dist/v2/headless.cjs 16.3 kB
packages/react-core/dist/v2/headless.mjs 15.8 kB
packages/react-core/dist/v2/index.cjs 4.04 kB
packages/react-core/dist/v2/index.mjs 4.03 kB
packages/react-core/dist/v2/index.umd.js 123 kB
packages/react-native/dist/chunk-C0xms8kb.cjs 546 B
packages/react-native/dist/components/index.cjs 8.65 kB
packages/react-native/dist/components/index.mjs 8.45 kB
packages/react-native/dist/CopilotKitProvider-CjoPnabW.cjs 1.55 kB
packages/react-native/dist/CopilotKitProvider-D8sn7G_C.mjs 1.43 kB
packages/react-native/dist/headless.cjs 632 B
packages/react-native/dist/headless.mjs 373 B
packages/react-native/dist/index.cjs 6.52 kB
packages/react-native/dist/index.mjs 6.14 kB
packages/react-native/dist/polyfills.cjs 195 B
packages/react-native/dist/polyfills.mjs 195 B
packages/react-native/dist/polyfills/crypto.cjs 373 B
packages/react-native/dist/polyfills/crypto.mjs 381 B
packages/react-native/dist/polyfills/dom.cjs 540 B
packages/react-native/dist/polyfills/dom.mjs 550 B
packages/react-native/dist/polyfills/encoding.cjs 332 B
packages/react-native/dist/polyfills/encoding.mjs 307 B
packages/react-native/dist/polyfills/location.cjs 236 B
packages/react-native/dist/polyfills/location.mjs 244 B
packages/react-native/dist/polyfills/streams.cjs 371 B
packages/react-native/dist/polyfills/streams.mjs 339 B
packages/react-native/dist/streaming-fetch-BnQh3vBz.mjs 2.22 kB
packages/react-native/dist/streaming-fetch-BTESzLKX.cjs 2.27 kB
packages/react-textarea/dist/index.cjs 17.7 kB
packages/react-textarea/dist/index.mjs 17 kB
packages/react-textarea/dist/index.umd.js 18.5 kB
packages/react-ui/dist/index.cjs 25.2 kB
packages/react-ui/dist/index.mjs 24.5 kB
packages/react-ui/dist/index.umd.js 26.4 kB
packages/runtime-client-gql/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/runtime-client-gql/dist/client/conversion.cjs 1.52 kB
packages/runtime-client-gql/dist/client/conversion.mjs 1.45 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.cjs 1.58 kB
packages/runtime-client-gql/dist/client/CopilotRuntimeClient.mjs 1.54 kB
packages/runtime-client-gql/dist/client/types.cjs 701 B
packages/runtime-client-gql/dist/client/types.mjs 642 B
packages/runtime-client-gql/dist/graphql/@generated/gql.cjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/gql.mjs 850 B
packages/runtime-client-gql/dist/graphql/@generated/graphql.cjs 2.4 kB
packages/runtime-client-gql/dist/graphql/@generated/graphql.mjs 2.36 kB
packages/runtime-client-gql/dist/graphql/definitions/mutations.cjs 740 B
packages/runtime-client-gql/dist/graphql/definitions/mutations.mjs 732 B
packages/runtime-client-gql/dist/graphql/definitions/queries.cjs 316 B
packages/runtime-client-gql/dist/graphql/definitions/queries.mjs 304 B
packages/runtime-client-gql/dist/index.cjs 679 B
packages/runtime-client-gql/dist/index.mjs 495 B
packages/runtime-client-gql/dist/index.umd.js 9.58 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.cjs 1.72 kB
packages/runtime-client-gql/dist/message-conversion/agui-to-gql.mjs 1.7 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.cjs 1.56 kB
packages/runtime-client-gql/dist/message-conversion/gql-to-agui.mjs 1.53 kB
packages/runtime-client-gql/dist/package.cjs 181 B
packages/runtime-client-gql/dist/package.mjs 116 B
packages/shared/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/shared/dist/a2ui-prompts.cjs 2.85 kB
packages/shared/dist/a2ui-prompts.mjs 2.85 kB
packages/shared/dist/attachments/content.cjs 255 B
packages/shared/dist/attachments/content.mjs 253 B
packages/shared/dist/attachments/utils.cjs 1.83 kB
packages/shared/dist/attachments/utils.mjs 1.79 kB
packages/shared/dist/constants/index.cjs 362 B
packages/shared/dist/constants/index.mjs 345 B
packages/shared/dist/debug.cjs 454 B
packages/shared/dist/debug.mjs 452 B
packages/shared/dist/event-transforms/index.cjs 335 B
packages/shared/dist/event-transforms/index.mjs 165 B
packages/shared/dist/event-transforms/open-generative-ui-middleware.cjs 2.42 kB
packages/shared/dist/event-transforms/open-generative-ui-middleware.mjs 2.35 kB
packages/shared/dist/event-transforms/recorded-events.cjs 988 B
packages/shared/dist/event-transforms/recorded-events.mjs 925 B
packages/shared/dist/finalize-events.cjs 1.94 kB
packages/shared/dist/finalize-events.mjs 1.88 kB
packages/shared/dist/index.cjs 2.89 kB
packages/shared/dist/index.mjs 2.47 kB
packages/shared/dist/index.umd.js 30.7 kB
packages/shared/dist/intelligence-routing-fields.cjs 778 B
packages/shared/dist/intelligence-routing-fields.mjs 775 B
packages/shared/dist/logger.cjs 112 B
packages/shared/dist/logger.mjs 112 B
packages/shared/dist/package.cjs 181 B
packages/shared/dist/package.mjs 116 B
packages/shared/dist/standard-schema.cjs 740 B
packages/shared/dist/standard-schema.mjs 737 B
packages/shared/dist/telemetry/index.cjs 358 B
packages/shared/dist/telemetry/index.mjs 250 B
packages/shared/dist/telemetry/lambda-client.cjs 1.59 kB
packages/shared/dist/telemetry/lambda-client.mjs 1.58 kB
packages/shared/dist/telemetry/model-host.cjs 1.63 kB
packages/shared/dist/telemetry/model-host.mjs 1.62 kB
packages/shared/dist/telemetry/sampling.cjs 956 B
packages/shared/dist/telemetry/sampling.mjs 935 B
packages/shared/dist/telemetry/telemetry-client.cjs 1.88 kB
packages/shared/dist/telemetry/telemetry-client.mjs 1.83 kB
packages/shared/dist/telemetry/telemetry-disabled.cjs 454 B
packages/shared/dist/telemetry/telemetry-disabled.mjs 451 B
packages/shared/dist/telemetry/utils.cjs 321 B
packages/shared/dist/telemetry/utils.mjs 277 B
packages/shared/dist/transcription-errors.cjs 951 B
packages/shared/dist/transcription-errors.mjs 944 B
packages/shared/dist/utils/clipboard.cjs 407 B
packages/shared/dist/utils/clipboard.mjs 405 B
packages/shared/dist/utils/conditions.cjs 540 B
packages/shared/dist/utils/conditions.mjs 536 B
packages/shared/dist/utils/console-styling.cjs 1.23 kB
packages/shared/dist/utils/console-styling.mjs 1.21 kB
packages/shared/dist/utils/errors.cjs 4.51 kB
packages/shared/dist/utils/errors.mjs 4.41 kB
packages/shared/dist/utils/index.cjs 1.45 kB
packages/shared/dist/utils/index.mjs 1.77 kB
packages/shared/dist/utils/inspector-learning.cjs 2.38 kB
packages/shared/dist/utils/inspector-learning.mjs 2.38 kB
packages/shared/dist/utils/inspector-metadata.cjs 1.46 kB
packages/shared/dist/utils/inspector-metadata.mjs 1.45 kB
packages/shared/dist/utils/inspector-visibility.cjs 285 B
packages/shared/dist/utils/inspector-visibility.mjs 282 B
packages/shared/dist/utils/json-schema.cjs 1.97 kB
packages/shared/dist/utils/json-schema.mjs 1.91 kB
packages/shared/dist/utils/random-id.cjs 618 B
packages/shared/dist/utils/random-id.mjs 559 B
packages/shared/dist/utils/requests.cjs 706 B
packages/shared/dist/utils/requests.mjs 704 B
packages/shared/dist/utils/row-render-keys.cjs 3.38 kB
packages/shared/dist/utils/row-render-keys.mjs 3.36 kB
packages/shared/dist/utils/types.cjs 161 B
packages/shared/dist/utils/types.mjs 160 B
packages/voice/dist/_virtual/_rolldown/runtime.cjs 516 B
packages/voice/dist/index.cjs 175 B
packages/voice/dist/index.mjs 95 B
packages/voice/dist/index.umd.js 1.5 kB
packages/voice/dist/transcription/transcription-service-openai.cjs 495 B
packages/voice/dist/transcription/transcription-service-openai.mjs 434 B
packages/web-inspector/dist/assets/inspector-logo-kite.cjs 2.36 kB
packages/web-inspector/dist/assets/inspector-logo-kite.mjs 2.3 kB
packages/web-inspector/dist/assets/inspector-logo.cjs 4.32 kB
packages/web-inspector/dist/assets/inspector-logo.mjs 4.23 kB
packages/web-inspector/dist/components/learning-view.cjs 9.47 kB
packages/web-inspector/dist/components/learning-view.mjs 9.47 kB
packages/web-inspector/dist/index.cjs 131 kB
packages/web-inspector/dist/index.mjs 131 kB
packages/web-inspector/dist/index.umd.js 195 kB
packages/web-inspector/dist/lib/context-helpers.cjs 866 B
packages/web-inspector/dist/lib/context-helpers.mjs 835 B
packages/web-inspector/dist/lib/home-briefing.cjs 2.8 kB
packages/web-inspector/dist/lib/home-briefing.mjs 2.79 kB
packages/web-inspector/dist/lib/inspector-learning.cjs 754 B
packages/web-inspector/dist/lib/inspector-learning.mjs 732 B
packages/web-inspector/dist/lib/inspector-metadata.cjs 760 B
packages/web-inspector/dist/lib/inspector-metadata.mjs 750 B
packages/web-inspector/dist/lib/inspector-nav.cjs 668 B
packages/web-inspector/dist/lib/inspector-nav.mjs 649 B
packages/web-inspector/dist/lib/learning-setup.cjs 1.12 kB
packages/web-inspector/dist/lib/learning-setup.mjs 1.09 kB
packages/web-inspector/dist/lib/notification-loader.cjs 792 B
packages/web-inspector/dist/lib/notification-loader.mjs 786 B
packages/web-inspector/dist/lib/notifications.cjs 2.39 kB
packages/web-inspector/dist/lib/notifications.mjs 2.37 kB
packages/web-inspector/dist/lib/onboarding-prompt.cjs 2.38 kB
packages/web-inspector/dist/lib/onboarding-prompt.mjs 2.37 kB
packages/web-inspector/dist/lib/persistence.cjs 3.61 kB
packages/web-inspector/dist/lib/persistence.mjs 3.52 kB
packages/web-inspector/dist/lib/pop-out.cjs 1.07 kB
packages/web-inspector/dist/lib/pop-out.mjs 1.05 kB
packages/web-inspector/dist/lib/telemetry.cjs 5.59 kB
packages/web-inspector/dist/lib/telemetry.mjs 5.38 kB
packages/web-inspector/dist/lib/thread-selection.cjs 566 B
packages/web-inspector/dist/lib/thread-selection.mjs 563 B
packages/web-inspector/dist/package.cjs 181 B
packages/web-inspector/dist/package.mjs 116 B
packages/web-inspector/dist/styles/generated.cjs 20.1 kB
packages/web-inspector/dist/styles/generated.mjs 20 kB
packages/web-inspector/dist/styles/notification-article.cjs 1.44 kB
packages/web-inspector/dist/styles/notification-article.mjs 1.44 kB

compressed-size-action

BenTaylorDev and others added 3 commits October 3, 2026 19:03
…renders

The previous commit wrapped the methods in arrow functions inside the
useMemo, so every state change handed callers new functions. The bare
prototype methods had a stable identity, and code such as
useEffect(..., [start]) relied on that. The wrappers are now useCallback
keyed on the agent. A new test fails on the previous commit and passes here.

Refs #3132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapper that dropped run's arguments or its returned promise still passed
the suite. One test now checks that run forwards its parameters to runAgent
and resolves to its result. Another calls start as a method of the hook
result, which also failed on main, because `this` was the result object.

Refs #3132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
start and run called agent.runAgent() directly. That skipped the core's
copilotkit.runAgent, so a run carried none of the config that useCoAgent
sets with setProperties, no registered frontend tools and no readable
context, and a frontend tool call the agent made never executed. The v1
chat path already goes through the core. stop now calls
copilotkit.stopAgent, which also cancels in-flight tool handlers and the
follow-up run.

run honors forwardedProps and runId from its first argument; the core
builds tools and context itself. The public type is unchanged.

The tests now drive a real CopilotKitCore. The config/tools/context test
and the tool-execution test fail on the previous commit, and a stop that
bypasses the core fails the stop test.

Refs #3132

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@BenTaylorDev BenTaylorDev changed the title fix(react-core): bind useCoAgent's start, run and stop to the agent fix(react-core): make useCoAgent's start, run and stop work, through the v2 core Oct 4, 2026
@BenTaylorDev
BenTaylorDev marked this pull request as ready for review October 5, 2026 04:02
…ed run resolves

The generated reference page still said run maps to the v2 agent's
runAgent(). The JSDoc for run now also says that a failed run resolves with
an empty result instead of rejecting, because the core catches the error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 42 services digest-pinned.

Run 2026-10-04 21:08:54 PDT — 0 finding(s).

@BenTaylorDev
BenTaylorDev merged commit 6373ce7 into main Oct 5, 2026
71 checks passed
@BenTaylorDev
BenTaylorDev deleted the ben1/3132-usecoagent-bind branch October 5, 2026 04:32
BenTaylorDev added a commit that referenced this pull request Oct 5, 2026
Follows from #7610: v1 `useCoAgent` called `agent.runAgent()` directly
and so skipped the core. The same pattern appears in eight v2 docs
examples.

## Problem

`agent.runAgent()` is the agent's low-level method. It does not send the
registered frontend tools or context, does not execute frontend tool
calls, and does not chain follow-up runs. In the core, tools and context
are attached only in `copilotkit.runAgent` and `connectAgent`
(`packages/core/src/core/run-handler.ts:608`, `:811`).
`programmatic-control.mdx` already names `copilotkit.runAgent({ agent
})` as "the recommended default", and the Vue `CopilotChatInput` page
already uses it. But eight examples showed `agent.runAgent()` for an
ordinary run, so code copied from them silently loses tools.

## Changes

| Page | Change |
|---|---|
| `integrations/langgraph/shared-state/in-app-agent-write.mdx`,
`integrations/deepagents/...` | "Re-run the agent with updated state"
calls `copilotkit.runAgent({ agent })`. The prose says why. |
| `whats-new/v1-50.mdx` | The multi-agent example runs each agent
through `copilotkit`. |
| `reference/components/CopilotChatInput.mdx` | The stop-button example
runs through `copilotkit.runAgent` and stops through
`copilotkit.stopAgent`, matching the Vue page. |
| `reference/hooks/useAgent.mdx`, `react-native/...`, `v1/...`,
`vue/...` | The `runAgent` method stays documented. It is now marked
low-level, says what it skips, and points to `copilotkit.runAgent`. It
also says that `copilotkit.runAgent` resolves instead of rejecting when
the run fails. The example is now an ordinary `forwardedProps` run
through the core. Interrupt answers point to `useInterrupt` or the
standard `resume` array, and `forwardedProps.command.resume` is labeled
legacy. The Vue example gains the `agent.value` null check that it needs
to typecheck. |
| `snippets/shared/basics/programmatic-control.mdx`,
`docs/programmatic-control.mdx` | The interrupt-resume guidance names
`copilotkit.runAgent({ agent, resume })` for standard interrupts and
labels the `forwardedProps.command.resume` form legacy. The shared
snippet no longer recommends `agent.runAgent()` for a resume. |

**Reviewed and left alone:**
- Every `thread.runAgent(...)`: the Channels server API, a different
method.
- `programmatic-control.mdx`: its comparison section is the source of
the guidance.
- The "what happens underneath" comment in
`snippets/shared/backend/ag-ui.mdx`: it describes the transport, and the
core does call `agent.runAgent()`.
- The `headless-threads` prose: it is about which thread a run
addresses.
- `dev-docs/architecture/setup-vanilla.md`: a deliberate
zero-abstraction `HttpAgent` example that already says "You lose tools,
context".
- `examples/showcases/grok-generative-ui/README.md`: already labels
`agent.runAgent()` "wrong".

`deepagents` and `langgraph` (`docs_mode: generated`) both render their
own `shared-state/in-app-agent-write` page, because the root has no file
for that slug.

## Testing

None of these blocks has a `doctest` attribute, so CI does not compile
them. I typechecked each new snippet against the real packages instead.

- **React** (`in-app-agent-write`, `v1-50`, `CopilotChatInput`, and the
`useAgent` example; React Native re-exports the same hooks): a probe
file in `packages/react-core/src` under `tsc --noEmit -p tsconfig.json`
gives no errors. A control line with `copilotkit.runAgent({ agentt: 1
})` in the same probe reports `TS2561 ... 'agentt' does not exist in
type 'CopilotKitCoreRunAgentParams'`, so the probe was really checked.
- **Vue**: the same check under `vue-tsc --noEmit` in `packages/vue`.
The snippet as first written failed with `Type 'AbstractAgent | null' is
not assignable to type 'AbstractAgent'`. The old
`agent.value.runAgent(...)` had the same flaw. With the null check, it
gives no errors, and the control line reports `TS2561`.
- **MDX syntax**: all eight files parse with
`unified().use(remarkParse).use(remarkMdx)`, the parser
`scripts/doc-tests/extract.ts` uses. A deliberately broken control file
fails it.
- **Standard `resume` snippet**: a probe in `packages/core/src` under
`tsc --noEmit` accepts `copilotkit.runAgent({ agent, resume: [{
interruptId: interrupt.id, status: "resolved", payload }] })` and the
new `forwardedProps` example. A control line with `status: "resolvd"`
reports `TS2820 ... not assignable to type '"cancelled" | "resolved"'`.
- **Not done**: a live render of the docs site.

**Overlap**: open PR #7476 also edits
`reference/components/CopilotChatInput.mdx`, in different sections.

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


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

* **Documentation**
* Updated agent execution examples to use the CopilotKit runner, which
includes frontend tools and context and handles frontend tool calls.
* Clarified that direct agent execution is a low-level option, while the
CopilotKit runner reports run failures to error subscribers instead of
rejecting.
* Explained standard interrupt resumption and distinguished it from the
legacy custom-event approach.
<!-- 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.

1 participant