Repository navigation
Conversation
…ng of JSON Some models send an object-typed tool argument as a string containing JSON. Haiku did, with an object `schema` argument, and the call failed: "Parameter validation error: Type mismatch. Expected: [schema (ObjectSchema, required)]". When a parameter's schema is an ObjectSchema or ArraySchema and the value is a string, it is decoded as JSON and used only if it is exactly that JSON type: an object, or a list. Invalid JSON or the wrong JSON type passes through unchanged and fails exactly as before. A string-typed parameter is never decoded, and neither is one whose handler declares `string`. Tests enter as CallsTools calls a tool, call_user_func_array on handle(...) with the model's named arguments. The decode test fails without the change; the others are controls that pass either way.
This branch has not been deployed
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.
Some models send an object-typed tool argument as a string containing JSON. Haiku did, with an object
schemaargument, and the call failed withParameter validation error: Type mismatch. Expected: [schema (ObjectSchema, required)].When a parameter's schema is an
ObjectSchemaorArraySchemaand the value is a string,Toolnow decodes it as JSON and uses it only if it is exactly that JSON type: an object, or a list. Invalid JSON or the wrong JSON type passes through unchanged and fails exactly as before. A string-typed parameter is never decoded, and neither is one whose handler declaresstring.It sits beside the scalar and BackedEnum coercion already in
coerceArguments(). Tests enter the wayCallsToolscalls a tool (call_user_func_array($tool->handle(...), $toolCall->arguments())). The decode test fails without the change; the rest are controls. Full suite, phpstan and rector pass.Third of the smaller PRs out of #1028.