fix: accept JSON string inputs in update_assets_tool (AICHAT-595)#213
Closed
mothership-ai[bot] wants to merge 1 commit intomainfrom
Closed
fix: accept JSON string inputs in update_assets_tool (AICHAT-595)#213mothership-ai[bot] wants to merge 1 commit intomainfrom
mothership-ai[bot] wants to merge 1 commit intomainfrom
Conversation
MCP clients (e.g. ChatGPT, remote MCP proxies) may serialize tool parameters as JSON strings rather than native dicts/lists. When FastMCP/Pydantic validates these inputs, string values are rejected with "Input should be a valid dictionary (got input_type=str)". Add explicit Union[..., str] type annotations to the assets and attribute_values parameters so Pydantic accepts string inputs. The existing parse_json_parameter/parse_list_parameter utilities in the function body already handle string-to-dict/list conversion. Closes AICHAT-595 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Closing - fix needs to go in agent-toolkit-internal (the hosted version customers use), not the OSS repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Union[..., str]type annotations toupdate_assets_toolparameters (assetsandattribute_values) so FastMCP/Pydantic validation accepts JSON string inputs from MCP clientsparse_json_parameter/parse_list_parameterutilities already handle string→dict/list conversion in the function body; this change ensures strings pass Pydantic validation before reaching that codeContext
MCP clients (ChatGPT, remote MCP proxies) may serialize tool parameters as JSON strings rather than native JSON objects. This causes Pydantic validation errors like:
updates.dict[any,any]: Input should be a valid dictionary (gotinput_type=str)updates.list[any]: Input should be a valid list (gotinput_type=str)Applies the same defensive parsing pattern established in PR #87.
Linked: AICHAT-595 | ZD #120072
Test plan
parse_json_parameter— dict passthrough, list passthrough, string→dict, string→list, None, invalid JSONparse_list_parameter— list passthrough, string→list, single value wrap, None, string→dict wrapupdate_assets_tool— assets as JSON string, attribute_values as JSON string, both as strings, list of assets as string, invalid JSON error, native dict passthrough, readme update with string params🤖 Generated with Claude Code