CertKeen

AWS Generative AI Developer Professional (AIP-C01) · Free practice question 11 of 12

Returning tool results in Converse

A developer at Ainsley Grocers calls the Converse API with a toolConfig. The model responds with stopReason tool_use and a toolUse block for a get_stock tool. After running the function, how should the developer continue the conversation?

  1. A.Send an assistant message with the function output as plain text and no tool identifier
  2. B.Send a user message with a toolResult block that has the same toolUseId
  3. C.Start a new Converse call with only the function output in the system field
  4. D.Put the function output in inferenceConfig and resend the original user message
Show answer and explanation

Correct answer: B. Send a user message with a toolResult block that has the same toolUseId

Why: In Converse tool use, the application executes the requested tool and returns the output in a toolResult content block within a user message, referencing the toolUseId from the model's request, along with the prior turns. Assistant-role plain text breaks the protocol. A fresh call without history loses context. inferenceConfig holds generation parameters only.

More free AWS Generative AI Developer Professional (AIP-C01) questions