-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Update ToolsTab parameter handling to omit optional empty fields #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ToolsTab parameter handling to omit optional empty fields #625
Conversation
87bb31e to
754c979
Compare
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Import JsonSchemaType from utils/jsonUtils - Cast tool.inputSchema to JsonSchemaType instead of any - Matches typing pattern used elsewhere in codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes parameter handling in the ToolsTab component to properly distinguish between required and optional fields. When optional tool parameters are cleared in the UI, they are now set to undefined and omitted from tool call requests instead of being sent as empty strings.
Key changes:
- Created a parameter cleaning utility that omits empty optional fields while preserving required fields
- Updated ToolsTab input handlers to set optional fields to
undefinedwhen cleared - Integrated parameter cleaning into the tool call request flow
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
client/src/utils/paramUtils.ts |
New utility for cleaning parameters based on JSON schema requirements |
client/src/utils/__tests__/paramUtils.test.ts |
Comprehensive test suite for parameter cleaning functionality |
client/src/components/ToolsTab.tsx |
Updated input handlers to set optional fields to undefined when cleared |
client/src/App.tsx |
Integrated parameter cleaning into the tool call request flow |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
1cf9efa to
45abfe0
Compare
…pty strings; update tests for new behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
… generation for optional types
…ervo/inspector into omit-optional-empty-strings-updated
| if (isFieldRequired) { | ||
| // Required fields: always include, even if empty string or falsy | ||
| cleaned[key] = value; | ||
| } else { | ||
| // Optional fields: only include if they have meaningful values | ||
| if (value !== undefined && value !== "" && value !== null) { | ||
| cleaned[key] = value; | ||
| } | ||
| // Empty strings, undefined, null for optional fields → omit completely | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a simplification:
| if (isFieldRequired) { | |
| // Required fields: always include, even if empty string or falsy | |
| cleaned[key] = value; | |
| } else { | |
| // Optional fields: only include if they have meaningful values | |
| if (value !== undefined && value !== "" && value !== null) { | |
| cleaned[key] = value; | |
| } | |
| // Empty strings, undefined, null for optional fields → omit completely | |
| } | |
| } | |
| // Include all required fields, and optional fields if they have meaningful values | |
| if (isFieldRequired || (value !== undefined && value !== "" && value !== null)) { | |
| cleaned[key] = value; | |
| } |
Forget the optimization, we are blocked by failing tests on main that this fixes.
Summary
undefinedand omitted from tool call requestsMotivation and Context
Fixes #623
When tool parameters are cleared in the UI, they were being sent as empty strings.
How Has This Been Tested?
Breaking Changes
None
Types of changes
Checklist