Run the same voice AI agent and tool handler through Amazon Bedrock by changing the agent class and Bedrock settings.
The claim
You swap the base class and the SDK’s agents/bedrock.py renders the base document, then rebuilds the verb as amazon_bedrock. The prompt, SWAIG, params, global_data and post-prompt settings are copied over. Inside the prompt it adds voice_id, temperature and top_p; its comment says that in Bedrock the voice configuration is part of the prompt object. It also drops three text-model prompt settings if you set them. The bundled schema documents the verb as AmazonBedrock. The SWAIG.functions list renders the same on both, and because one configure() registers the tool on each agent, the same handler runs on both.
How it works
def configure(agent):
agent.prompt_add_section("Role", "You are the parts desk at Ridgeline Cycles. ...")
agent.define_tool(name="check_stock",
description="Check whether a bike part is in stock before promising it.",
parameters=PARAMETERS, handler=check_stock)
return agent
def build(kind="bedrock"):
if kind == "ai":
return configure(AgentBase(name="parts", route="/parts"))
return configure(BedrockAgent(name="parts", route="/parts", voice_id="matthew"))
One configure() builds the desk on either class, so there is one place the prompt and the tool live. AGENT_KIND in the environment picks which one python app.py serves, BEDROCK_VOICE_ID picks the voice, and any other kind stops the process with a message.
Limitations
You prove the documents and the handler. What the Bedrock model does with the prompt and the voice, and how it sounds, are the platform’s side of a live call. The tool keeps the SDK’s secure default, so each render carries a per-call token in its webhook URL; the verifier compares the URLs without it.
BedrockAgent drops barge_confidence, presence_penalty and frequency_penalty from the prompt if you set them; the comment in agents/bedrock.py calls them text-model settings. The verifier sets none, so it does not exercise that.
What to change first
Give the Bedrock desk a different tool description in configure() by branching on isinstance(agent, BedrockAgent), and run the verifier. The functions-equal assertion fails. The recipe’s point is that you do not have to branch.