Skip to content

Conversation

@kairosci
Copy link
Contributor

@kairosci kairosci commented Jan 18, 2026

Background

The ToolApprovalRequest type is currently missing toolName and input properties. This PR adds comprehensive type tests to tool.test-d.ts and explicitly demonstrates the broken behavior by asserting existence of these properties, which causes the tests to fail.

Summary

  • Updated packages/provider-utils/src/types/tool.test-d.ts to be comprehensive for the current state, including tests for:
    • Callbacks
    • Strict mode
    • Provider/Dynamic tools
    • Type helpers
    • ToolApprovalRequest (failing test to demonstrate missing properties)

Manual Verification

Ran pnpm vitest run packages/provider-utils/src/types/tool.test-d.ts --typecheck and verified that it fails as expected due to missing properties.

Checklist

  • Tests have been added / updated
  • I have reviewed this pull request

*/
export const DEFAULT_EMPTY_INPUT_SCHEMA = {
type: 'object',
properties: {},
Copy link
Contributor

@vercel vercel bot Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default schema when tool.inputSchema is undefined is missing 'additionalProperties: false', causing inconsistent validation behavior compared to other parts of the codebase.

Fix on Vercel

@kairosci kairosci closed this Jan 18, 2026
@kairosci kairosci deleted the fix/5527-default-empty-input-schema branch January 18, 2026 22:43
@kairosci kairosci restored the fix/5527-default-empty-input-schema branch January 18, 2026 22:44
@kairosci kairosci reopened this Jan 18, 2026
@kairosci kairosci marked this pull request as draft January 18, 2026 22:46
return tool;
return {
...tool,
inputSchema: tool.inputSchema ?? DEFAULT_EMPTY_INPUT_SCHEMA,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tool() function assigns a plain object (DEFAULT_EMPTY_INPUT_SCHEMA) to inputSchema instead of wrapping it in a FlexibleSchema, violating the Tool type contract.

Fix on Vercel

*/
export const DEFAULT_EMPTY_INPUT_SCHEMA = {
type: 'object',
properties: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent validation behavior: DEFAULT_EMPTY_INPUT_SCHEMA lacks 'additionalProperties: false', causing schema to allow additional properties during validation despite the provider rejecting them

Fix on Vercel

@kairosci kairosci closed this Jan 19, 2026
@kairosci kairosci deleted the fix/5527-default-empty-input-schema branch January 19, 2026 00:05
@kairosci kairosci reopened this Jan 19, 2026
@kairosci kairosci changed the title feat(provider-utils, ai): default to empty object for tools without inputSchema [duplicate] feat(provider-utils, ai): default to empty object for tools without inputSchema Jan 19, 2026
@kairosci kairosci force-pushed the fix/5527-default-empty-input-schema branch 2 times, most recently from 9a69e3c to 4a741b9 Compare January 19, 2026 09:00
@kairosci kairosci force-pushed the fix/5527-default-empty-input-schema branch from 4a741b9 to c88dc6a Compare January 19, 2026 09:04
@kairosci kairosci changed the title [duplicate] feat(provider-utils, ai): default to empty object for tools without inputSchema fix(provider-utils): add toolName and input to ToolApprovalRequest and comprehensive type tests Jan 19, 2026
@kairosci kairosci changed the title fix(provider-utils): add toolName and input to ToolApprovalRequest and comprehensive type tests fix(provider-utils): add comprehensive type tests showing missing properties in ToolApprovalRequest Jan 19, 2026
@kairosci kairosci changed the title fix(provider-utils): add comprehensive type tests showing missing properties in ToolApprovalRequest fix(provider-utils): add comprehensive type tests showing broken behavior Jan 19, 2026
@kairosci kairosci force-pushed the fix/5527-default-empty-input-schema branch from 1450d06 to 11e6cea Compare January 19, 2026 21:56
@kairosci
Copy link
Contributor Author

@lgrammel I have added the requested tests, demonstrating that the type definitions are currently incomplete as the TypeScript check now fails

@kairosci
Copy link
Contributor Author

Since it was asked to prove the problem, I created code to verify the initial hypothesis, which at the moment has no corrections.

So as it should be, TypeScript does not pass.

(Prettier is to be formatted, but I think it's the least of the problems)

@lgrammel
Copy link
Collaborator

@kairosci thanks for creating the tests. I meant that in this PR, the tests should describe the current behavior (even if wrong), i.e. they should just specify what exists. In the follow up PR that fixes the issue, we would change the tests to show the breakage, and then fix it. This approach will make it very clear in the 2nd PR what behavior was changed and how, making it easier to think about (e.g. re backwards compatibility).

Can you adjust this PR such that the tests encode the existing behavior, even if buggy?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants