Repository navigation
fix(a2ui): omit component schemas from catalog context when includeSchema is false (React, Vue, Angular) - #7810
Conversation
…includeSchema is false
buildCatalogContextValue always embedded the JSON schema of every custom
component in the "A2UI catalog capabilities" context entry, so
`a2ui={{ includeSchema: false }}` still sent all of them to the agent.
It now takes an optional `{ includeSchema }` argument. When it is false,
custom components are listed by name only. A2UICatalogContext passes the
provider's flag through. The default output is unchanged.
Fixes CopilotKit#7802
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Catalog context builders packages/a2ui-renderer/src/react-renderer/catalog-utils.ts, packages/angular/src/lib/components/a2ui/a2ui-catalog-context.ts, packages/vue/src/v2/components/a2ui/A2UICatalogContext.ts, packages/*/a2ui/*catalog-context* tests |
The builders accept includeSchema and omit custom component schemas when it is false. Tests cover default inclusion, explicit inclusion, omission, and unchanged basic-catalog output. |
Provider context wiring and documentation packages/react-core/src/v2/a2ui/A2UICatalogContext.tsx, packages/angular/src/lib/copilotkit.ts, packages/vue/src/v2/components/a2ui/A2UICatalogContext.ts, packages/* provider tests and documentation, examples/v2/docs/reference/copilotkit-provider.mdx, showcase/shell-docs/src/content/* |
Provider paths pass the setting to catalog context generation. Angular returns after adding catalog context when schemas are disabled, so it omits the additional schema and guideline contexts. Provider tests and documentation describe the option and its context behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- None. The retrieved issue is directly linked to this pull request.
Merge Risk: 
Minimal · up to 3e535
-
No actionable merge-blocking risk remains in the reviewed changes.
Pre-merge checks: 
3 · 
2
-
Failed checks: 2 warnings Passed checks: 3 passed-
Full details: Out of Scope Changes check
-
Explanation
The changes support
#7802. They include: theincludeSchemaoption onbuildCatalogContextValuein React, Vue and Angular; forwarding of the provider flag inA2UICatalogContext.tsx,registerA2UICatalogContextandCopilotKit(Angular); and builder and provider tests. The documentation updates describe thefalsebehavior and the LangGraph consequence. The docs cover thea2uiprop, the Angular A2UI guide and theprovideCopilotKitreference. The basic-catalog output is unchanged and no unrelated module is modified. The PR description notes an overlap with#6550incatalog-utils.ts, but that overlap does not add unrelated behavior in this diff. The LangGraph middleware files are referenced in the docs and not modified in a way that changes behavior.
-
Full details: Linked Issues check
-
Explanation
Issue
#7802has two coding requirements. The title and Expected Behavior both state that the default path must send each custom component schema once. Requirement 1,includeSchema: falseomits custom component schemas, is implemented.buildCatalogContextValuereceivesincludeSchemain React (packages/a2ui-renderer,packages/react-core), Vue (packages/vue/src/v2/components/a2ui/A2UICatalogContext.ts) and Angular (a2ui-catalog-context.ts,copilotkit.ts). Tests assert the same literal names-only string. Requirement 2 is unmet. At head,A2UICatalogContext.tsxcallsbuildCatalogContextValue(catalog, { includeSchema: includeSchema !== false }), which embeds schemas when the flag istrueor unset. The same component also buildsschemaValuefromextractCatalogComponentSchemas(catalog)and registers it underA2UI_SCHEMA_CONTEXT_DESCRIPTION. Each custom schema therefore still appears twice in the default path. The PR description defers this as option 2. That decision does not remove the requirement from the linked issue, and no default-path test checks single emission.Resolution
In the default path (
includeSchemaunset ortrue), emit each custom component schema once. Preferred approach: remove schemas from the capabilities entry and keep the component-schema entry, as the issue suggests. Apply the same change in React, Vue and Angular so the three frameworks stay aligned. Add context-registration tests that assert one schema payload per component for the default and explicittruepaths. If the maintainers instead decide to keep the duplicate, record that decision in the issue and do not close#7802with this PR.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 14 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · 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.
Comment @coderabbitai help to get the list of available commands.
…cludeSchema is false
The Vue and Angular providers build their own "A2UI catalog capabilities"
context entry and, like React did, always embedded every custom
component's JSON schema in it, so `includeSchema: false` still sent them.
Both builders now take an optional `{ includeSchema }` argument and list
custom components by name only when it is false, producing the same
string as the React builder. The providers pass their `includeSchema`
setting through. Output with `includeSchema: true` (the default) is
unchanged, as is the `- <catalogId>` line the LangGraph middleware reads.
The `includeSchema` JSDoc on the React, Vue and Angular providers now says
what `false` still sends, and that a LangGraph A2UI subagent then gets
component names only unless the host passes a composition guide through
the middleware's guidelines.
Refs CopilotKit#7802
With `includeSchema: false` the A2UI catalog context still carries the catalog ID and custom component names, without schemas or the generation and design guidelines. Say so in the Vue and Angular provider references, the Angular A2UI guide and the React provider reference in examples, and note that a LangGraph A2UI subagent then gets component names only unless the host passes a composition guide through the middleware's guidelines. Refs CopilotKit#7802
BenTaylorDev
left a comment
There was a problem hiding this comment.
Thanks for picking up the Vue and Angular copies so quickly. The code does what we asked. With includeSchema: false, all three frameworks now send the catalog ID and the custom component names only. With true, the output is the same as before. I checked this through a real CopilotKitProvider render. On main, the capabilities entry was 655 characters with both schemas. On this branch, it is 160 characters with names only. The default output is byte-identical. I also checked the LangGraph consumers in sdk-js, sdk-python and the ag-ui toolkit. They still read the catalog ID from the - <catalogId> line, and a host composition guide still wins. Your new tests fail when I put back the main source, which is what we want.
Two things are left before this can merge.
-
React provider reference in the live docs. The file you edited,
examples/v2/docs/reference/copilotkit-provider.mdx, is the old example docs site. It is not the published docs. The live React reference isshowcase/shell-docs/src/content/reference/components/CopilotKit.mdx. Itsa2uientry, near line 192, is typed as{ theme?: Theme }and does not mentionincludeSchema. Please addincludeSchemathere, with the same text you used for Vue and Angular. Say thatfalsestill sends the catalog ID and custom component names. Add the LangGraph note too: the A2UI subagent gets names only, and a host can passa2uiParams.guidelines.compositionGuideora2ui_params["guidelines"]["composition_guide"]. You can leave theexamples/v2/docsedit in or take it out. -
A React provider-level test. Vue and Angular each have a test that mounts the provider and checks the registered capabilities value. React only tests
buildCatalogContextValue. Nothing checks thatA2UICatalogContextpassesincludeSchemathrough. Please add a react-core test that rendersCopilotKitProviderwitha2ui={{ catalog, includeSchema: false }}and asserts the exact capabilities value fromcopilotkit.context. Also cover the default case. Do not mockA2UICatalogContext. One tip: the react-core test setup pinsrandomUUIDfrom@copilotkit/sharedto one value. Override it in the test, or the four context entries will overwrite each other.
The branch is behind main but merges cleanly, so you do not need to rebase for this. Thanks again.
|
@BenTaylorDev thanks for the thorough check. Both are pushed:
No rebase, just two commits on top. |
@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-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/mcp-apps-renderer
@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
left a comment
There was a problem hiding this comment.
Both follow-ups check out. The React reference now types a2ui with its real fields and documents what includeSchema: false still sends, with the LangGraph note. The new provider test renders a real CopilotKitProvider without mocking A2UICatalogContext; it passes on this branch merged with current main, and with A2UICatalogContext.tsx reverted to main the includeSchema: false case fails while the default case passes. Thanks for turning both around so fast.
I bless the code with a glad heart
What does this PR do?
a2ui={{ includeSchema: false }}is meant to stop component schemas being sent to the agent, but the "A2UI catalog capabilities" context entry always embedded every custom component's JSON schema. With a 5-component catalog that was still ~10k characters of agent context with the flag off. React, Vue and Angular each build this entry with their own copy of the logic, and all three had the gap.Following option 1 from #7802: when
includeSchemaisfalse, the capabilities entry lists the catalog ID and the custom component names only, without JSON schemas. All three frameworks now send the same string for the same catalog:buildCatalogContextValue(packages/a2ui-renderer) takes an optional{ includeSchema }argument;A2UICatalogContext(packages/react-core) passes the provider's flag through.packages/vue/src/v2/components/a2ui/A2UICatalogContext.ts;registerA2UICatalogContextpasses the provider'sincludeSchemathrough (still reactive).packages/angular/src/lib/components/a2ui/a2ui-catalog-context.ts;CopilotKitpassesa2ui.includeSchemathrough.What stays the same:
includeSchema: true(the default) the entry is byte-for-byte unchanged in all three frameworks, including the full schemas.- <catalogId>first line and the entry's description are unchanged, so the LangGraph middleware still finds the entry and reads the catalog ID from it.LangGraph consequence
The LangGraph middleware (
packages/sdk-js/src/langgraph/middleware.ts,sdk-python/copilotkit/copilotkit_lg_middleware.py) finds this entry by its "A2UI catalog" description and passes its whole value to the injected A2UI tool's subagent as the composition guide. So a host that setsincludeSchema: falseand uses the injected A2UI tool now gives the subagent the component names only, not their schemas. That matches whatfalsesays it does. A host that wants the subagent to have more can still pass a composition guide through the middleware's guidelines, which take precedence over the catalog entry:createCopilotkitMiddleware({ a2uiParams: { guidelines: { compositionGuide } } })CopilotKitMiddleware(a2ui_params={"guidelines": {"composition_guide": ...}})Docs
includeSchemaJSDoc on the React, Vue and Angular providers now says whatfalsestill sends (catalog ID and custom component names; no schemas, no generation/design guidelines) and the LangGraph note above.CopilotKit, VueCopilotKitProviderand AngularprovideCopilotKit, plus the Angular A2UI guide (showcase/shell-docs/src/content/...), and the older example docs pageexamples/v2/docs/reference/copilotkit-provider.mdx.Tests
catalog-utils.test.tscovers default,true,false(exact string) and the basic catalog, plus provider tests inCopilotKitProvider.a2ui.test.tsxchecking the registered capabilities value withincludeSchema: falseand by default.A2UICatalogContext.test.tsfor the builder, plus provider tests inCopilotKitProvider.a2ui.test.tschecking the registered capabilities value withincludeSchema: falseand by default.a2ui-catalog-context.spec.tsfor the builder, pluscopilotkit.spec.tstests checking the registered capabilities value withincludeSchema: falseand by default.The
falsetests assert the same literal string in all three packages.Not in this PR: the duplicate schemas when
includeSchemaistrue(option 2 in the issue), which the maintainers chose to leave as is for now.Related PRs and Issues
catalog-utils.ts(Zod v4 conversion); the overlap is small.Checklist
!(not breaking)Summary by CodeRabbit