File tree Expand file tree Collapse file tree 2 files changed +5
-15
lines changed
Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -26,19 +26,16 @@ export function getStringArg(
2626
2727 let value = args [ argName ] ;
2828
29- // Handle case where JSON content was parsed into an object by the tool call parser.
29+ // Handle case where JSON was parsed into an object by the tool call parser.
3030 // If the arguments to the tool call are valid JSON (e.g. the model attempts to create a .json file)
31- // the earlier call to JSON.parse() will have deeply parsed the returned contents .
31+ // the earlier call to JSON.parse() will have deeply parsed the returned arguments .
3232 // If that has happened, convert back to string.
3333 if ( typeof value === "object" && value !== null ) {
34- // Special handling for contents parameter which should always be a string
35- if ( argName === "contents" ) {
34+ try {
3635 value = JSON . stringify ( value ) ;
3736 return value ;
38- } else {
39- throw new Error (
40- `Argument \`${ argName } \` must be a string, not an object` ,
41- ) ;
37+ } catch ( e ) {
38+ //Swallow this, because it might be fine later.
4239 }
4340 }
4441
Original file line number Diff line number Diff line change @@ -176,13 +176,6 @@ describe("getStringArg", () => {
176176 expect ( result ) . toBe ( '["item1","item2",{"key":"value"}]' ) ;
177177 } ) ;
178178
179- it ( "should throw error when non-contents parameter is an object" , ( ) => {
180- const args = { filename : { invalid : "object" } } ;
181- expect ( ( ) => getStringArg ( args , "filename" ) ) . toThrowError (
182- "Argument `filename` must be a string, not an object" ,
183- ) ;
184- } ) ;
185-
186179 it ( "should handle contents parameter that is already a string" , ( ) => {
187180 const args = { contents : "already a string" } ;
188181 const result = getStringArg ( args , "contents" ) ;
You can’t perform that action at this time.
0 commit comments