Amazon Bedrock Converse API Tool Use Planner: toolConfig and toolSpec JSON Schemas, toolChoice Options, the tool_use Stop Reason Loop, toolResult Error Status, Inference Profiles, and boto3 Code
Ppromptstudio·Oct 9, 2026
No rating
Plan a tool calling agent on Amazon Bedrock with the Converse API: write toolSpec definitions with inputSchema JSON, choose auto, any, or a forced tool, run the stopReason tool_use loop that returns toolResult blocks, mark tool errors with status, pick an inference profile ID, and get working boto3 code plus a test checklist.
Act as an AWS generative AI engineer who builds tool using assistants on Amazon Bedrock with the model agnostic Converse API in boto3 (bedrock-runtime client, converse and converse_stream).
Inputs:
- Model and how it is reached: model ID or inference profile ID copied from the Bedrock console, plus region and whether model access is enabled: [ModelId]
- Tools the assistant needs: name, what it does, its parameters with types and allowed values, and the backend call behind it: [ToolList]
- Conversation flow: what the user asks, which tool should run when, and when the model must answer without a tool: [ConversationFlow]
- Error policy: what happens on timeouts, not found, permission denied, and bad arguments: [ErrorPolicy]
- Runtime limits: max tool rounds per request, latency budget, streaming or not, logging rules for PII: [RuntimeLimits]
- Output format: [Format]
Generate:
1. A toolConfig block: one toolSpec per tool in ToolList with a name, a description written for the model (when to use it and when not to), and inputSchema.json with types, enums, required fields, and additionalProperties false.
2. A toolChoice decision: auto for normal turns, any when a tool call is required, or tool with a name to force one tool, and a note to check that the chosen model supports that option.
3. A system prompt block (system list of text) that states the ConversationFlow rules and tells the model never to invent tool results.
4. The request loop in Python: call converse with modelId, messages, system, inferenceConfig (maxTokens, temperature), and toolConfig; when stopReason is tool_use, append the assistant message, run each toolUse block, and send one user message with matching toolResult blocks by toolUseId; stop at end_turn or the round cap from RuntimeLimits.
5. Error handling from ErrorPolicy: return a toolResult with status error and a short text the model can explain to the user, and retry throttling exceptions with backoff.
6. Argument validation before running any backend call, rejecting values outside the schema.
7. A test checklist: one prompt per path in ConversationFlow, a forced error case, a no tool question, and the usage fields (inputTokens, outputTokens) to log per round.
Constraints:
- Read the model ID from configuration; never hardcode or guess an ID.
- Never execute a tool the model names unless it is in ToolList.
- Keep secrets and PII out of logs per RuntimeLimits. No em dashes.