Repository navigation
Conversation
The v1.0 schema generator replaced the common types' DataBinding,
FunctionCommon and IndexSystemFunction with hand-written schemas that
took v0.9's bare `path` or `call` beside `@path` or `@call`. The v1.0
common types allow only the `@` keys, and DataContext reads only them at
v1.0, so a v1.0 payload written with `{"path": ...}` or `{"call": ...}`
passed PayloadValidator and MessageProcessor, in strict mode too, and
was then drawn as the literal object.
The generator now emits the three definitions from the v1.0 common
types as written: `@path` and `@call` are required, and a DataBinding
takes no other key. The literal branch of DynamicValue excludes only
`@path` and `@call`, as the common types define it, so a plain object
with `path` or `call` keys stays a literal.
Catalogs loaded with Catalog.fromJson resolve their common type
references in the cross-version superset in types/common-types.ts, which
still takes both spellings; that is left for its own change.
Tests that sent a v1.0 message with the bare keys move to the `@` keys:
web_core's callRendererFunction fixtures, the Angular v1.0 rendering
spec, and two catalog-mcp callMcpTool tests, one of which now calls the
tool through a v1.0 DataContext. The comment above callMcpTool's
imports no longer says the v1.0 schemas take the v0.9 keys. The
@a2ui/agent case for a callFunction written with `call` expects the
message schema's error, which now reports it before the agent's own
check.
There was a problem hiding this comment.
Code Review
This pull request introduces a breaking change for v1.0 schemas (including DataBinding, FunctionCommon, and IndexSystemFunction) by strictly requiring the '@path' and '@call' keys and rejecting the v0.9 'path' and 'call' keys. Corresponding updates have been made to the schema generator, tests, and test configurations. The review feedback highlights that helper functions 'isArgumentsCall' and 'resolveToolArguments' in 'callMcpTool.ts' must be updated to support '@call' to avoid treating v1.0 function calls as plain records, and suggests adding a test case to verify this behavior.
| // The argument schemas come from the v1.0 entry point, so a v1.0 payload binding a tool argument | ||
| // with `@path` or `@call` validates when the surface is processed. The message types stay the v0.9 | ||
| // ones, which describe every payload a tool result may carry. |
There was a problem hiding this comment.
With the transition to strictly requiring @call and @path in v1.0, isArgumentsCall and resolveToolArguments (defined further down in this file) need to be updated to support @call.
Currently, isArgumentsCall only checks for call, args, and returnType:
function isArgumentsCall(value: unknown): value is FunctionCall {
return (
isFunctionCall(value) &&
Object.keys(value).every(key => key === 'call' || key === 'args' || key === 'returnType')
);
}Because @call is not in that list, any v1.0 function call passed as the entire arguments object will not be recognized as a function call, and resolveToolArguments will treat it as a plain record instead of executing it.
Additionally, resolveToolArguments needs to pass @call to resolveDynamicValue:
function resolveToolArguments(
value: FunctionCall | Record<string, unknown>,
context: DataContext,
): unknown {
if (!isArgumentsCall(value)) {
return resolveDynamicRecord(value, context);
}
return context.resolveDynamicValue({
'@call': value['@call'] ?? value.call,
'args': value.args ?? {},
'returnType': value.returnType ?? 'any',
} as any);
}Please update both functions to fully support @call for v1.0.
There was a problem hiding this comment.
This predates this PR: main behaves the same. On a v1.0 surface, web_core's DataContext resolves an @call in arguments before callMcpTool runs, so the tool receives the call's result. Only a direct catalog.invoker call with an unresolved v1.0 call reaches isArgumentsCall. The suggested change would not catch that case either: isFunctionCall in dynamic-values.ts requires a string call, so {"@call": ...} still fails it. Making catalog-mcp's resolver read the v1.0 keys is a separate change, noted in #4346, so I've kept it out of this PR.
| it('parses dynamic data bindings in name and arguments', () => { | ||
| const parsed = CallMcpToolApi.schema.parse({ | ||
| name: {path: '/selectedTool'}, | ||
| arguments: {city: {path: '/user/city'}, count: 10}, | ||
| name: {'@path': '/selectedTool'}, | ||
| arguments: {city: {'@path': '/user/city'}, count: 10}, | ||
| }); | ||
| assert.deepStrictEqual(parsed, { | ||
| name: {path: '/selectedTool'}, | ||
| arguments: {city: {path: '/user/city'}, count: 10}, | ||
| name: {'@path': '/selectedTool'}, | ||
| arguments: {city: {'@path': '/user/city'}, count: 10}, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Since we are strictly using @call and @path in v1.0, we should also add a test case to verify that a v1.0 function call passed as the entire arguments object is parsed correctly. Currently, there is only a v0.9 test case for this (takes the result of a function call as the arguments, without resolving it again).
it('parses dynamic data bindings in name and arguments', () => {
const parsed = CallMcpToolApi.schema.parse({
name: {'@path': '/selectedTool'},
arguments: {city: {'@path': '/user/city'}, count: 10},
});
assert.deepStrictEqual(parsed, {
name: {'@path': '/selectedTool'},
arguments: {city: {'@path': '/user/city'}, count: 10},
});
});
it('parses a v1.0 function call as the whole arguments object', () => {
const call = {'@call': 'transformData', args: {jmespath: '{path: @}', data: {path: '/dir'}}};
const parsed = CallMcpToolApi.schema.parse({name: 'list_directory', arguments: call});
assert.deepStrictEqual(parsed, {name: 'list_directory', arguments: call});
});There was a problem hiding this comment.
This test already passes on this branch, because {"@call": ...} parses as a plain record of tool arguments, so it wouldn't show that the call is recognized. A test for that belongs with the resolver change noted in #4346.
|
Hi @retz8, Thank you for raising the pr to fix the issue. We have verified the pr and it does resolve the issue. I will escalate this to team to review. Thank you for your patience and understanding. |
…e-path-call # Conflicts: # typescript/core/web_core/CHANGELOG.md
…e-path-call # Conflicts: # typescript/core/web_core/CHANGELOG.md
Problem
In web_core, a v1.0 payload that writes a binding or a call with v0.9's keys,
{"path": ...}or{"call": ...}, passesPayloadValidatorandMessageProcessor, in strict mode too. At v1.0DataContextreads only@pathand@call, so the surface renders the object itself. #4346 has the mechanism.This PR fixes it for catalogs built on web_core's v1.0 schemas, such as the basic catalog and
@a2ui/catalog-mcp. Catalogs loaded withCatalog.fromJson, which validate against the cross-version superset, are left for their own change. A v1.0 producer that still writes plainpathandcallnow gets a validation error, so the CHANGELOG entry marks this as breaking.@a2ui/agent's renderer function calls and the Python Atom compiler already write the@keys at v1.0.Part of #4346.
Changes
@a2ui/web_core:src/v1_0/scripts/generate-schemas.mjsno longer replaces the v1.0 common types'DataBinding,FunctionCommonandIndexSystemFunctionwith hand-written schemas that take both spellings. It emits them fromspecification/v1_0/json/common_types.jsonas written:@pathand@callare required, and aDataBindingtakes no other key, as itsadditionalProperties: falsesays and as the Python core's v1.0DataBindingdoes. The generator's literal-object branch ofDynamicValueexcludedpathandcallas well as@pathand@call. It now excludes only the@keys, as the common types'not: {anyOf: [{required: ["@path"]}, {required: ["@call"]}]}does. Without that, a plain object withpathorcallkeys, whichtest_plain_object_with_literal_path_and_calland the spec'sdynamic_value_validation.jsonaccept, would match no branch.src/v1_0/schema/common-types.tsis regenerated.Unchanged: the superset in
src/types/common-types.ts, whichCatalog.fromJsoncatalogs validate against;DataContext; and the RPC handler, which still falls back tocallwhen@callis absent.Changed tests. Each wrote v1.0 data with plain
pathorcalland relied on the old schemas accepting them:processing/message-processor.test.ts: 11callRendererFunctionfixtures move fromcallto@call. The v1.0 spec requires@callthere, and@a2ui/agent's renderer function calls and the Python Atom compiler write it at v1.0. One of them is the case that expects a call withoutcatalogIdto be refused. Withcallit would now also be refused for the missing@call, so it moves to keep testing what it says.v1_0.spec.ts: the v1.0TextField'svalueand its check'sconditionmove to@path.functions/callMcpTool.test.ts: the schema test of bindings innameandargumentsmoves to@path. The test of resolving those bindings called the invoker directly with v0.9 bindings, which catalog-mcp's own resolver read. It now callscallMcpToolthrough a v1.0DataContextwith@pathbindings, as a v1.0 surface does.createTestDataContexttakes an optional protocol version for it. The comment abovecallMcpTool.ts's imports no longer says the v1.0 schemas accept the v0.9 keys.@a2ui/agentutils/renderer-function-call-validation.test.ts: acallFunctionwritten withcallis now refused by the message schema ("'@call' is a required property") before the agent's own check ("is missing a string '@call' field"), so the case expects that message.The moved web_core and catalog-mcp tests pass on
maintoo.Tests
PayloadValidator rejects v0.9's bare path and call keys as v1.0 dynamic valuesincatalogs/basic/v1/basic_catalog_elements.test.ts. Onmainit fails withMissing expected exception (A2uiValidationError): expected {"path":"/name"} to be rejected. Its last assertion, a literalDynamicValueholdingpathandcallkeys, fails when the generator'sDynamicValuebranch is put back as it was.{"path"}and{"call"}, and@path,@calland v0.9 resolve as before. TheCatalog.fromJsonlines are unchanged.On this branch:
@a2ui/web_core:test1659/1659;tests/conformance/conformance_test.mjs830/830 passed, 1072 skipped, as onmain; ESLint 0 errors, and 822 warnings as onmain@a2ui/agent: 2070 passed, 441 skipped@a2ui/catalog-mcp:test:node196/196,test:karma227/227,test:types@a2ui/react:test:unit540 passed, 1 skipped@a2ui/lit:test:unit161 passed@a2ui/catalog-vegachart26/26,@a2ui/markdown-it,widget-builder32/32,@a2ui/lit-explorer,@a2ui/react-explorer./scripts/fix_format.sh --check: Prettier and pyink pass. Its Dart step fails onmaintoo, since fix(dart/core): report unknown envelope keys at their paths #4197, indart/a2ui_core/lib/src/processing/processor.dartandtest/processor_test.dart, which this PR does not touch.Not run:
@a2ui/angular, whose Angular 22 CLI needs a newer Node than the one here. Instead, the changed spec's v1.0TextFieldwas run through web_core'sMessageProcessoron this branch: as it was, it is rejected, and with@pathit is accepted. Also not run:scripts/e2e_test.sh, andfix_licenses.py(no new files).Pre-launch Checklist
One time:
For this PR:
If you need help, consider asking for advice on the discussion board.