Skip to content

Commit 8451f14

Browse files
committed
fix: do not add readOnly fields to the requestBody
According to the spec readOnly fields SHOULD NOT be sent in the request, but maybe present in the response. The LLM has made several errors making calls when these fields are present by including the readOnly fields in the request and getting HTTP 422's. This change loops through the args, and drops readOnly fields from the requestBodyContent arg on the tool. Signed-off-by: Bill Maxwell <[email protected]>
1 parent 18a74f0 commit 8451f14

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/loader/openapi.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ func getOpenAPITools(t *openapi3.T, defaultHost string) ([]types.Tool, error) {
199199
arg.Description = content.Schema.Value.Description
200200
}
201201

202+
// Read Only can not be sent in the request body, so we remove it
203+
for key, property := range arg.Properties {
204+
if property.Value.ReadOnly {
205+
delete(arg.Properties, key)
206+
}
207+
}
202208
// Unfortunately, the request body doesn't contain any good descriptor for it,
203209
// so we just use "requestBodyContent" as the name of the arg.
204210
tool.Parameters.Arguments.Properties["requestBodyContent"] = &openapi3.SchemaRef{Value: arg}

0 commit comments

Comments
 (0)