Verify Amazon Ergo Tool Calling With Bedrock Converse

Verify Amazon Ergo tool calling with a two-request Bedrock Converse script. Validate one local lookup, return its result, and diagnose where a run stops.

Amazon Ergo tool calling illustrated as two Converse message cards joined by a matching toolUseId, with the demo-417 local lookup between them.Amazon Ergo tool calling illustrated as two Converse message cards joined by a matching toolUseId, with the demo-417 local lookup between them.
Illustrative release lookup. The application validates the tool request, reads the fixture, and returns its result with the same toolUseId. Based on the AWS client-side tool-use guide.

Your Python client can get an answer from Bedrock before it has demonstrated that it can complete a tool call. To verify Amazon Ergo tool calling, give the model one synthetic build ID and let it request the release channel from a local Python function. The test passes when Python validates and runs the lookup once, returns the result to the same conversation, and receives an end_turn response that says staging.

AWS announced Amazon Ergo availability on Bedrock on December 1, 2026. This exercise uses the US cross-Region inference profile and the non-streaming Converse API. You can run it before changing a coding agent’s provider configuration, which makes it easier to see whether a failure starts with AWS access, local dispatch, or the return of the tool result. AWS availability announcement

Pick the inference target and isolate the fixture

  1. Use Python with Boto3 in a development environment where the SDK can resolve your existing AWS development identity. The script constructs a bedrock-runtime client with region_name="us-west-2" and passes us.amazon.ergo-1.0 as modelId. The Region names the endpoint to which Python submits the request. The inference profile selects the model and its routing scope. AWS lists us-west-2 as a supported source Region for the US profile and documents that Ergo requires cross-Region inference. Amazon Ergo model card
  2. Confirm that the existing identity is authorized for this target. The Converse API requires bedrock:InvokeModel on the inference target and the project. The script omits projectIdentifier, so the account’s default project applies. If access is denied, give your administrator the profile ID, source Region, and project context. The policy example in the Ergo coding-tool guide identifies inference-profile and foundation-model resource types and also covers streaming and the Global profile. Converse API reference · AWS Ergo coding-tool setup
  3. Run the first test with the supplied fixture unchanged and outside the coding agent. The only build is demo-417, and the Python function reads its staging value from an in-memory dictionary. The tool requires no release database, deployment client, or file access. The two Converse calls use live model inference, for which AWS lists usage pricing. Amazon Ergo model card

Read the target at startup as a pair. For example, us-west-2 alongside us.amazon.ergo-1.0 tells you which endpoint and profile the script asked to use. In particular, the startup line says nothing about the destination Region that served a request. If a later adapter prints the right Region and the base ID amazon.ergo-1.0, compare the ID first. AWS explicitly calls for a profile ID for this model, even when the application submits from a supported US Region. Amazon Ergo model card · AWS Ergo coding-tool setup

The fixture has a known answer and a deliberately narrow input. The prompt includes the build ID, and the schema describes where to put it. The channel first appears in the payload sent to the model when Python returns the tool result. An early answer of staging would still fail because the test requires evidence of the local read and the result submission. With one in-memory lookup, you can also rule out a slow database or separate tool credential when following the output.

AWS What’s New page announcing Amazon Ergo availability on Amazon Bedrock.
AWS What’s New announcement for Amazon Ergo on Bedrock. · Original source

Run the two-request smoke test

  1. In your development Python environment, install or update Boto3 if necessary. AWS documents pip install -U boto3 for its Converse and InvokeModel examples. The python -m pip form below uses the same interpreter as the run command. If your development environment already has a working Boto3 installation with converse, go straight to the script. AWS Ergo coding-tool setup
  2. Save the complete example as ergo_release_lookup.py and run it from the environment with the approved development identity. Watch for the case and target line, the two stop reasons, the local lookup line between them, and the final PASS. The example output later in this guide is illustrative.
python -m pip install -U boto3
python ergo_release_lookup.py
import boto3
from botocore.exceptions import BotoCoreError, ClientError

CASE = "task:release-lookup-01"
REGION = "us-west-2"
MODEL = "us.amazon.ergo-1.0"
TOOL = "get_release_channel"
BUILD = "demo-417"
RELEASE_CHANNELS = {BUILD: "staging"}

TOOL_CONFIG = {
    "tools": [
        {
            "toolSpec": {
                "name": TOOL,
                "description": "Look up the release channel for a synthetic build ID.",
                "inputSchema": {
                    "json": {
                        "type": "object",
                        "properties": {"build_id": {"type": "string"}},
                        "required": ["build_id"],
                        "additionalProperties": False,
                    }
                },
            }
        }
    ]
}


def get_release_channel(build_id):
    return {"build_id": build_id, "channel": RELEASE_CHANNELS[build_id]}


def converse(client, stage, messages):
    try:
        response = client.converse(
            modelId=MODEL,
            messages=messages,
            toolConfig=TOOL_CONFIG,
            inferenceConfig={"maxTokens": 8192},
        )
    except ClientError as exc:
        error = exc.response["Error"]
        raise SystemExit(f"{stage} AWS {error['Code']}: {error['Message']}") from None
    except BotoCoreError as exc:
        raise SystemExit(f"{stage} SDK {type(exc).__name__}: {exc}") from None

    reason = response.get("stopReason")
    print(f"{stage} stopReason={reason}", flush=True)
    if reason == "max_tokens":
        usage = response.get("usage", {})
        raise SystemExit(
            f"{stage}: output token limit reached "
            f"(outputTokens={usage.get('outputTokens', 'unavailable')})"
        )
    return response


def assistant_message(response, stage):
    message = response.get("output", {}).get("message", {})
    if message.get("role") != "assistant" or not isinstance(message.get("content"), list):
        raise SystemExit(f"{stage}: missing assistant message")
    return message


def main():
    print(f"{CASE} modelId={MODEL} region={REGION}", flush=True)
    try:
        client = boto3.client("bedrock-runtime", region_name=REGION)
    except BotoCoreError as exc:
        raise SystemExit(f"client setup SDK {type(exc).__name__}: {exc}") from None

    prompt = {
        "role": "user",
        "content": [{"text": (
            f"Use {TOOL} once to look up the release channel for build {BUILD}. "
            "After receiving the result, reply with only the channel name."
        )}],
    }
    first = converse(client, "request 1", [prompt])
    if first.get("stopReason") == "end_turn":
        raise SystemExit("request 1: ended without a tool round trip")
    if first.get("stopReason") == "malformed_tool_use":
        raise SystemExit("request 1: Bedrock reported malformed_tool_use")
    if first.get("stopReason") != "tool_use":
        raise SystemExit("request 1: expected tool_use")

    assistant = assistant_message(first, "request 1")
    calls = [block["toolUse"] for block in assistant["content"] if "toolUse" in block]
    if len(calls) != 1 or not isinstance(calls[0], dict):
        raise SystemExit("request 1: expected exactly one toolUse object")
    call = calls[0]
    if call.get("name") != TOOL or call.get("type") == "server_tool_use":
        raise SystemExit("request 1: unexpected tool request")
    args = call.get("input")
    if not isinstance(args, dict) or args != {"build_id": BUILD}:
        raise SystemExit("request 1: invalid tool arguments for demo-417")
    call_id = call.get("toolUseId")
    if not isinstance(call_id, str) or not call_id.strip():
        raise SystemExit("request 1: missing toolUseId")

    result = get_release_channel(args["build_id"])
    print(f"local lookup {result['build_id']} -> {result['channel']}", flush=True)
    result_message = {
        "role": "user",
        "content": [{"toolResult": {
            "toolUseId": call_id,
            "content": [{"json": result}],
        }}],
    }
    second = converse(client, "request 2", [prompt, assistant, result_message])
    if second.get("stopReason") == "tool_use":
        raise SystemExit("request 2: unexpected second tool request")
    if second.get("stopReason") != "end_turn":
        raise SystemExit("request 2: expected end_turn")
    final = assistant_message(second, "request 2")
    if any("toolUse" in block for block in final["content"]):
        raise SystemExit("request 2: unexpected second tool request")
    answer = "".join(block["text"] for block in final["content"] if "text" in block)
    if answer.strip().casefold() != "staging":
        raise SystemExit("request 2: expected only staging after the lookup")
    print(f"PASS {CASE} answer={answer.strip()}")


if __name__ == "__main__":
    main()

toolConfig advertises the one function to the model. The nested toolSpec carries a name, a description, and the JSON schema for the argument object. Python uses the same toolConfig on both calls, following the pattern in AWS’s client-side Converse example. With toolChoice omitted, the default is automatic. This lets you see whether the model requests the advertised function from the prompt. AWS documents that forced choices depend on support from the particular model and can produce validation errors if unsupported. AWS client-side tool use · Boto3 Converse reference

The prompt specifies one call followed by the bare channel. That instruction gives the model a completion condition, while the Python branches enforce it. On a successful path, there are two application calls to client.converse and one direct call to get_release_channel. The script’s request labels refer to application calls. The SDK can retry certain service errors internally, so use those labels to identify which conversation step failed. Converse API reference

maxTokens limits output for each call. The Ergo coding-tool guide recommends allowing at least 8,192 tokens because the model uses some of the allowance for reasoning. A one-word expected answer can still consume tokens before visible text appears. The script starts with the same cap for each call and reports outputTokens from the returned usage object on a max_tokens stop. AWS Converse user guide · AWS Ergo coding-tool setup

Check what crossed the application boundary

Input Action Expected result
task:release-lookup-01 with build demo-417, fixture channel staging, profile us.amazon.ergo-1.0, and source Region us-west-2 Run python ergo_release_lookup.py. Request 1 advertises get_release_channel. Python validates one toolUse, reads the fixture, then sends request 2 with the original assistant message and matched toolUseId. Illustrative expected observation includes request 1 stopReason=tool_use, a single local lookup for demo-417, request 2 stopReason=end_turn, and PASS task:release-lookup-01 answer=staging.
Illustrative expected output

task:release-lookup-01 modelId=us.amazon.ergo-1.0 region=us-west-2
request 1 stopReason=tool_use
local lookup demo-417 -> staging
request 2 stopReason=end_turn
PASS task:release-lookup-01 answer=staging

Start at stopReason. On the first response, tool_use tells Python to look inside the assistant message. The script scans its content array because Boto3 represents a message as a list of tagged blocks, and other content may precede the toolUse block. Counting the tool blocks before dispatch means a response with two requests exits before either can run. A response with one correct call and one unexpected call also stops at the count check. Boto3 Converse reference

Next, inspect what the validator accepts. The requested name must equal get_release_channel, and the SDK’s server-tool marker is rejected. The input document must be exactly {"build_id": "demo-417"}. Comparing the whole dictionary checks the key, the build value, and the absence of extra arguments. For example, {"build_id": "demo-471"} might satisfy the advertised string schema, but it exits with invalid tool arguments for demo-417 before the local read. A JSON string containing an object also fails because the input must already be a dictionary. Boto3 Converse reference

A nonempty toolUseId completes the validation. Python then calls the function directly. The function reads the mapping and returns a dictionary with build_id and channel. The local lookup line prints only after the function returns and before the second Converse call. If you see local lookup demo-417 -> staging followed by an AWS error, that run reached the expected local result. Start your next inspection at the handoff or the service error on request 2.

Request 2 sends three messages. The first is the original user prompt, the second is the entire assistant message from request 1, and the third is a user message containing toolResult. Read the assistant message for validation and send it back intact. If the message carries signed reasoning content, AWS requires the signature and all previous messages on the follow-up. Copying a single toolUse block into a newly constructed assistant turn can lose that context. AWS Converse user guide

The toolResult carries the exact toolUseId returned by Bedrock for this call and places the fixture dictionary under content as a json block. Treat the ID as an opaque value. The build ID tells Python which record to read, and the tool use ID tells the receiving side which request the result answers. Both could appear in a debugger when following the lookup. Check the ID in the first assistant turn against the one inside the final user turn, character for character. AWS client-side tool use

Protocol sequence showing Converse requests between Python and Bedrock and a single dispatch to the local demo-417 fixture.Protocol sequence showing Converse requests between Python and Bedrock and a single dispatch to the local demo-417 fixture.
Illustrative protocol sequence. Python keeps the original assistant message and matches toolResult to toolUse by ID. Source: AWS client-side tool use and Converse user guide.

The second response must finish with end_turn and contain the expected text. The script joins the text blocks in order and ignores surrounding whitespace and capitalization. A bare Staging passes. A reply of The release channel is staging. fails the one-word assertion even though it includes the right value. If that happens, inspect the final text separately from the stop reason. You can record a closed tool exchange with an answer-format failure, which calls for checking the prompt and the text extraction. A bare production calls for checking the actual fixture result sent in request 2 before changing the assertion. Boto3 Converse reference

Diagnose the first stage that stops

Observation What happened in this run Check next
request 1 AWS AccessDeniedException The first call was denied before Python received a tool request. Verify the approved identity and its bedrock:InvokeModel access for the target and default project.
request 1 AWS ValidationException with an invalid model identifier or an in-Region invocation message AWS rejected the call before dispatch. Compare the exact modelId and source Region, then check access to the model in the account.
request 1 stopReason=end_turn The first turn finished before a tool round trip. Verify toolConfig and the prompt’s request for get_release_channel.
request 1 stopReason=malformed_tool_use Bedrock reported a malformed tool request. Record the stop reason and inspect the actual response before editing the fixture.
request 1: invalid tool arguments for demo-417 Python received a tool request and blocked dispatch. Compare the input object with the exact key and build value in the fixture.
Either request returns max_tokens Generation reached that call’s output limit. Read the request label and reported outputTokens, then check the configured per-call cap.
request 2 stopReason=tool_use The model asked for another tool after the local result was sent. End the run and inspect the assistant history and matched result.

Illustrative decision matrix pairing Bedrock Converse errors and stop reasons with the Python smoke test’s next check.Illustrative decision matrix pairing Bedrock Converse errors and stop reasons with the Python smoke test’s next check.
Illustrative failure matrix for the release lookup. Match the signal to the request stage before changing the test. Sources: AWS Converse API reference and Ergo coding-tool guide, consulted December 3, 2026.

Read the service error before changing the prompt. A line marked AWS carries the error code and message from the service. An SDK line identifies an exception the SDK raised outside that service-error branch. If the SDK cannot find credentials, confirm that the same environment that runs the script has your development session available. If AWS denies access, take the code and startup target pair to the person who can check the existing IAM policy and default project. When AWS says in-Region invocation of the base ID is unsupported, verify that MODEL still includes the us. profile prefix. For an invalid model identifier, confirm the exact value, supported source Region, and account access before adjusting the test. Converse API reference · AWS Ergo coding-tool setup

Find out whether the model requested the lookup. If the first response is end_turn, check that the initial call contains toolConfig and that the supplied prompt names the tool. Automatic choice can produce a text response, which is an incomplete smoke test even when the text happens to contain the correct channel. When tool_use appears and Python rejects the arguments, open the call object in a debugger before the get_release_channel line. Compare its name, input, and toolUseId with the validation checks. The service stop reason malformed_tool_use takes an earlier branch and identifies a failure before the Python validation checks run. AWS client-side tool use · Converse API reference

Use the request label on a token-limit stop. On request 1, max_tokens exits before even an apparently usable block can reach the lookup. On request 2, the lookup has already returned and the second response is incomplete for this test. The diagnostic prints that response’s outputTokens when available. Check the actual inferenceConfig on the failing call, especially if you moved the example into an adapter that sets its own limit. If you change the cap to investigate the stop, launch the script again from the original prompt so the next observation covers a complete exchange under one configuration. AWS Converse user guide · AWS Ergo coding-tool setup

Inspect the second request where the handoff is built. If request 2 gets a validation error after the local lookup, compare the outgoing message list with [prompt, assistant, result_message]. Check that the assistant message still contains all its original blocks, the result message has role user, and its toolResult has a matching ID and content containing the json block. If request 2 returns tool_use, inspect those same fields and confirm that the original prompt tells Ergo to answer after receiving the result. Even a repeated call for demo-417 exceeds the one-lookup contract and exits without further dispatch. AWS client-side tool use · AWS Converse user guide

Recover the caller and use the result

  1. Keep the coding agent on its current model while you run the standalone test. If you already introduced a temporary override in the agent, restore the last known-good provider, model ID, and endpoint or Region together. Remove the override at the scope where you added it, for example in a development configuration or a launcher environment. If the only changes were inside the standalone Python file, close that process and continue from the agent’s usual configuration.
  2. Open a fresh development session if the agent loaded the temporary override. Read the effective model and provider in the caller’s existing status display or startup diagnostics. Run the small request you normally use with the old provider. Recovery is complete when the caller resolves its previous target and answers through its usual path. Model selection inside a managed harness can be verified separately. Test a model override in an AgentCore session
  3. Save what the test actually printed with the integration change. Record task:release-lookup-01, the Region and profile, the stop reasons you received, whether local dispatch ran, and the pass line or first failure. For a service error, keep the stage and code. These fields let the next developer compare the same case without copying credentials or entire messages into a shared record. What you need to replay an agent run

If the direct test passes but a harness fails, start with the stage that differs. A harness that fails before dispatch might be resolving a different target or project. Ask for the effective profile and project from the harness invocation and compare them with the standalone assumptions. If project enrollment is in dispute, inspect the project’s effective access as a separate check. Verify effective Bedrock project enrollment

If the harness reaches its local read and then fails, compare the returned message and tool result at the integration boundary. In a framework that handles message replay and tool execution, verify the same fixture through the framework’s public entry point and keep its result alongside the direct script’s output. That gives you evidence about the actual adapter you plan to use. Build a Spring AI Bedrock tool integration

A validation failure also gives you a concrete case for regression testing. For example, if a run requested demo-471, keep a sanitized copy of the structured argument and record that the expected behavior is an exit before the local lookup. Pair it with the accepted demo-417 input, which should reach dispatch. That pair checks the application decision when you later refactor the validator, while the live Converse smoke test still checks the complete handoff through Bedrock. Backtest a wrong tool lookup with LangSmith

Sources

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater