anybody having trouble with using bedrock converse api with tools? I'm facing one and clueless
according to this note:
https://github.com/halllo/DotnetAgentExperiments/?tab=readme-ov-file#awssdkbedrockruntime
and the corresponding git diff:
https://github.com/halllo/DotnetAgentExperiments/commit/81a7257d781227d9e1d18b77c70fe367522ffef0
and their https://stackoverflow.com/questions/79397902/function-calling-with-claude-on-amazon-bedrock-in-net-core
the type, properties and required fields shouldn't start with capital letters, but that is not the case in your example either.
the only thing which looks like a suspect is that kebab-cased customer-id json key name.
while it is completely valid in json to have arbitrary strings in keys, an implementation might be overly strict, so i would try the call with customerId, just to see, if this validation error goes away.
{:message "The value at toolConfig.tools.0.toolSpec.inputSchema.json.type must be one of the following: object.",
:cognitect.aws.http/status 400,
:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.aws.error/code "ValidationException"}
(aws/invoke @bedrock-runtime-client {:op :Converse :request {:modelId "apac.anthropic.claude-sonnet-4" :messages [{:role "user" :content [{:text "how many cars are there?"}]}] :toolConfig {:tools [{:toolSpec {:name "get-user-cars" :description "Get all devices for a customer." :inputSchema {:json {:type "object" :properties {:customer-id {:type "string"}} :required ["customer-id"]}}}}]} :inferenceConfig {:maxTokens 512 :temperature 0.5 :topP 0.9}}})
• changing "object" to :object ,"Object", "object." didn't work. • writing the value of :json key to json/write-str didn't work. and many other combinations all fail. perhaps the problem is not with the validation? for the spec of the parameter, https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use-inference-call.html is quite straightforward.
; :toolConfig
; {:tools
; [:seq-of
; {:toolSpec
; {:name string, :description string, :inputSchema {:json document}},
; :cachePoint {:type [:one-of ["default"]]}}],
from aws/docsno matter what I put, the value of :json key is always an empty map.
still doesn't work 😾
{:message "The value at toolConfig.tools.0.toolSpec.inputSchema.json.type must be one of the following: object.",
:cognitect.aws.http/status 400,
:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.aws.error/code "ValidationException"}
does anyone know whom I should reach out for?
filed an issue here https://github.com/cognitect-labs/aws-api/issues/272
that's a good start. the error message is coming back from the aws http api though, so what i would try to do is to check what is the raw http request sent to their api, because that's probably the one, which is deformed somehow. to get a hold on the raw request, i would 1. read the docs, to see if there is a documented way to do so 2. read the source, to see, which function should i redefine to capture the raw request 3. i vaguely remember there was an option to pass in some custom http clients to the various aws service clients, so i would wrap the default client with some instrumentation which captures the request before sending it out
yea I did that already. The request had am empty map {} where there should be the value of :json key. Do you know where I can view the source code? from what I know cognitect uploads libraries directly
u should share in that ticket how were you looking into the request, since that's an important step in reproducing the issue.
re: source code
it's in the service-specific jar files.
i don't think it's published elsewhere in any different format.
they i generated automatically, iirc, but i don't know how to generate them from scratch, locally.
so just look inside files like ~/.m2/repository/com/cognitect/aws/s3/871.2.30.22/s3-871.2.30.22.jar
on intellij, with cursive, u can see these under the External Libraries branch of the project tree tool window.
but cider or clojure-mode in emacs also support browsing jar files, just simply navigate into the cognitect.aws.s3.specs ns, for example, with cider-find-var (`M-.`), assuming u have loaded it already.
seems like my case is https://github.com/cognitect-labs/aws-api/issues/270.