Skip to content

Bedrock Converse API with tool use drop integers ≥ 2^31 (toolUse.input becomes {}) and sometimes coerce to strings — repro on Llama 3.1 & Mistral Large

0

Service: Amazon Bedrock

API: converse with toolConfig (JSON Schema)

Region: us-west-2

Models tested:

  • meta.llama3-1-70b-instruct-v1:0
  • mistral.mistral-large-2407-v1:0

Summary

When using the Converse API with tool use and a JSON-Schema declaring "type": "integer" for tool inputs, certain large integer values cause the runtime to drop the entire tool input: the model chooses the tool (stopReason: "tool_use"), but toolUse.input is {}.

This happens at and above 2^31 (2147483648), and also at 2^32 (4294967296). Strangely, much larger integers (e.g., 2^53−1 and 2^53) are accepted but are returned as strings, despite the schema declaring "integer".

This breaks common cases like epoch-millisecond timestamps in tool parameters.

Expected

  • Integers within 64-bit range should be accepted and delivered (ideally as integers).
  • If coercion to string is intended, it should be consistent and documented—not dropping the input silently for specific ranges.

Actual

  • For values ≥ 2^31 (tested) and at 2^32, toolUse.input becomes {}.
  • For very large values (2^53−1, 2^53), values are preserved but as strings in toolUse.input.

Minimal Repro (Python)

import boto3, json

client = boto3.client("bedrock-runtime", region_name="us-west-2")
MODEL_ID = "meta.llama3-1-70b-instruct-v1:0"  # also occurs with "mistral.mistral-large-2407-v1:0"

tool_config = {
    "tools": [{
        "toolSpec": {
            "name": "test_instana_tool",
            "description": "Test tool for large integers",
            "inputSchema": {
                "json": {
                    "type": "object",
                    "properties": {
                        "var_from":   {"type": "integer"},
                        "to":         {"type": "integer"},
                        "window_size":{"type": "integer"}
                    },
                    "required": ["var_from","to","window_size"]
                }
            }
        }
    }],
    "toolChoice": {"auto": {}}
}

def run(val):
    prompt = f"Use test_instana_tool with var_from={val}, to={val}, window_size=60000"
    resp = client.converse(
        modelId=MODEL_ID,
        messages=[{"role":"user","content":[{"text": prompt}]}],
        toolConfig=tool_config
    )
    rid = resp["ResponseMetadata"]["RequestId"]
    content = resp["output"]["message"]["content"]
    inputs = [c.get("toolUse", {}).get("input") for c in content if "toolUse" in c]
    print(val, rid, inputs)

for v in [2147483647, 2147483648, 4294967296, 9007199254740991, 9007199254740992]:
    run(v)

Observed RequestIds (Llama 3.1, Converse)

  • 2147483647 (2^31−1)cf6db05f-6cda-4b8a-984b-4695bb52cefe → accepted; strings:

    {"var_from":"2147483647","to":"2147484647","window_size":"60000"}
  • 2147483648 (2^31)7fe71e43-74f6-4059-bd02-edc583d143ffinput dropped: {}

  • 4294967296 (2^32)287c0398-db10-4538-8ca8-0d2eceee10f4input dropped: {}

  • 9007199254740991 (2^53−1)ba1e21cf-4a8d-45e4-bfc8-77aa63be5d8f → accepted; strings

  • 9007199254740992 (2^53)45ba204a-5c24-4cc6-abc1-327f540d2dd9 → accepted; strings

Also repro’d with Mistral Large (Converse)

  • mistral.mistral-large-2407-v1:0: model selects tool, but toolUse.input is {} for large integers (example RequestId from a separate run: e8d55358-11fb-4471-b150-108e1257dace).

Questions

  1. What integer width does the Converse tool input validator support for "type":"integer"? (Should be at least int64.)
  2. Why are some large values coerced to strings while others are dropped? Is this a known issue with the global validator or a model-adapter quirk?
  3. Is there a supported schema hint (e.g., format: int64) that Converse honors to prevent dropping values?
  4. Can AWS confirm and provide an ETA or recommended best practice for 64-bit integer tool parameters (e.g., epoch-ms)?

asked a year ago267 views

2 Answers
0

This appears to be a bug in the Amazon Bedrock Converse API's handling of large integers when using tool configurations with JSON schemas.

Based on your detailed reproduction, there seems to be inconsistent behavior with integer handling in tool inputs:

  1. Integers below 2^31 (2147483648) are accepted but converted to strings
  2. Integers at or above 2^31 and at 2^32 cause the entire tool input to be dropped (empty object)
  3. Very large integers (2^53-1 and above) are accepted but coerced to strings

This behavior appears to be consistent across different models (both Llama 3.1 and Mistral Large), suggesting it's an issue with the Bedrock Converse API's JSON schema validation rather than model-specific.

For your specific use case with epoch-millisecond timestamps, the current workaround would be to:

  1. Define your schema properties as "type": "string" instead of "type": "integer"
  2. Handle the string-to-integer conversion in your application code after receiving the response

This issue appears similar to other known quirks with the Converse API, such as problems with escaping quotes in tool calls. Since this seems to be a bug in the service rather than expected behavior, opening a support ticket with AWS would be the recommended approach to get an official response regarding the expected integer width support and timeline for a fix.

For now, using string types in your schema and handling the conversion in your application is likely the most reliable approach until this issue is addressed.
Sources
Llama 3.1 Converse calls not properly escaping quotes in tool calls | AWS re:Post
Bedrock Converse API - Consistent Timeout Issue with Larger models like Anthropic Sonnet 3.5 and Meta Llama 405B | AWS re:Post

answered a year ago

0

Hello,

Q 1: What integer width does the Converse tool input validator support for "type":"integer"? (Should be at least int64.) Answer : I'd like to kindly note that "integer" is actually not a supported JSON schema type - we currently use "number". However, the good news is that we now support a broader range of numerical values.

Q 2: Why are some large values coerced to strings while others are dropped? Is this a known issue with the global validator or a model-adapter quirk? Answer: This behavior is actually a model-specific characteristic rather than a validator issue.

Q 3: Is there a supported schema hint (e.g., format: int64) that Converse honors to prevent dropping values? Answer: Unfortunately, at this time there isn't a supported schema hint available for this purpose.

Q 4: Can AWS confirm and provide an ETA or recommended best practice for 64-bit integer tool parameters (e.g., epoch-ms)? Answer: While we understand the importance of this feature, we regrettably don't have a specific timeline to share at the moment. We're continuously working to improve our services and appreciate your patience on this matter.

Thank you.

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.