Skip to content

Add an @openuidev/copilotkit adapter for OpenUI tool rendering #1100

Description

@vishxrad

Is your feature request related to a problem? Please describe.

CopilotKit applications already own the chat shell, conversation state, AG-UI transport, and tool lifecycle. There is no first-party OpenUI adapter for rendering streamed OpenUI Lang inside CopilotKit tool calls. Applications must currently register tools, inject the OpenUI component instructions, map streaming status, handle human input, and restore submitted form state themselves.

This is different from using OpenUI's AG-UI adapter with AgentInterface. In this case CopilotKit remains the host shell and OpenUI renders generated interfaces inside its tool-call extension points.

Describe the solution you'd like

Add a focused @openuidev/copilotkit package under packages/copilotkit, modeled on the existing @openuidev/assistant-ui integration.

Proposed behavior:

  • Register present_openui through CopilotKit v2 useFrontendTool for display-only UI, with followUp: false.
  • Register prompt_openui through useHumanInTheLoop for forms and choices that pause until the user responds.
  • Render partial streamed ui arguments with OpenUI Renderer and openuiChatLibrary.
  • Generate model instructions from the same OpenUI library used by the renderer.
  • Return @ToAssistant action context, parameters, form name, and form state through CopilotKit's tool result flow.
  • Restore submitted form state when completed tool calls are replayed from conversation history.
  • Apply an OpenUI ThemeProvider by default, with an opt-out for applications that already own the theme boundary.
  • Support custom libraries, prompt options, tool names, renderer options, and error handling.
  • Add focused unit and renderer tests, package documentation, API reference documentation, and a small runnable CopilotKit example for browser validation.

The adapter would target CopilotKit v2 from @copilotkit/react-core/v2. The current published @copilotkit/react-core version is 1.69.3.

Division of responsibility:

  • CopilotKit owns the chat shell, agent connection, messages, tool execution, and continuation.
  • OpenUI owns the generated UI language, streaming parser, component library, rendering, interaction state, and action payloads.

Describe alternatives you've considered

  1. Document an app-local integration only. This leaves every application to duplicate status mapping, prompt generation, action serialization, and replay behavior.
  2. Add CopilotKit directly to @openuidev/react-ui. This would make an optional chat shell a dependency or peer of the main React UI package.
  3. Use OpenUI AgentInterface with the AG-UI adapter. That is useful when OpenUI owns the shell, but it does not address applications where CopilotKit must remain the shell.

A separate adapter package keeps the host-specific dependency isolated and matches the existing assistant-ui package boundary.

Additional context

Proposed interaction path:

CopilotKit chat -> model tool call -> streamed OpenUI Lang -> OpenUI Renderer
CopilotKit chat <- next model turn <- tool result <- follow-up or form action

Planned validation includes:

  • display-only chart rendering with no raw OpenUI Lang visible;
  • a FollowUpBlock item producing exactly one new CopilotKit turn;
  • a validated form submission carrying distinctive form values into exactly one new turn;
  • streamed partial arguments, parser error handling, theme application, and replayed form state;
  • package typecheck, tests, lint, build, publint, and package export checks.

If this package boundary and scope are acceptable, I can implement it on a linked branch and open a pull request after approval.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions