From cfa565e1bbf5aeadd1537e4cfd909d711ae6d50e Mon Sep 17 00:00:00 2001 From: sjw1231 Date: Wed, 11 Nov 2026 14:23:30 +0800 Subject: [PATCH] fix(cua): label a top-level request issue as arguments A key outside method and params reported an empty field name; it now reads arguments: Unrecognized key, matching how other issues name their field. Refs #7869 --- .../cua-macos/tests/provider-lifecycle.spec.ts | 9 +++++++++ packages/experimental/cua/src/index.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/experimental/cua-macos/tests/provider-lifecycle.spec.ts b/packages/experimental/cua-macos/tests/provider-lifecycle.spec.ts index 942d6e1f28..d5cd4d3fc6 100644 --- a/packages/experimental/cua-macos/tests/provider-lifecycle.spec.ts +++ b/packages/experimental/cua-macos/tests/provider-lifecycle.spec.ts @@ -626,6 +626,15 @@ it('names the missing field of a request that matches none of its accepted forms expect(native.request).not.toHaveBeenCalled() }) +it('names an unknown top-level request key', async () => { + const f = await setup() + const result = await executeToolFixture(f.ctx, { + agent: f.handle.agent, signal: new AbortController().signal, callId: ToolCallId('extra-key'), name: 'cua', + arguments: { method: 'listApps', params: {}, extra: 1 }, + }) + expect(result.content).toEqual([{ type: 'text', text: 'Error: invalid arguments: arguments: Unrecognized key: "extra"' }]) +}) + it('rejects malformed and unowned operations before acquiring a helper', async () => { const f = await setup() const malformed = await f.execute('screenshot', { pid: 9, windowId: '7' }) diff --git a/packages/experimental/cua/src/index.ts b/packages/experimental/cua/src/index.ts index da78cb8c84..6992e1b61e 100644 --- a/packages/experimental/cua/src/index.ts +++ b/packages/experimental/cua/src/index.ts @@ -102,7 +102,7 @@ function executionAgent(execution: Readonly): Agent { */ function requestViolation(issue: z.core.$ZodIssue, base: readonly PropertyKey[] = []): string { const path = [...base, ...issue.path] - const field = path.map(String).join('.') + const field = path.length > 0 ? path.map(String).join('.') : 'arguments' if (issue.code !== 'invalid_union' || issue.errors.length === 0) return `${field}: ${issue.message}` const forms = issue.errors.map(form => `(${form.map(nested => requestViolation(nested, path)).join('; ')})`) return `${field}: matches none of the accepted forms: ${forms.join(' or ')}`