GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Bug] @ai-sdk/amazon-bedrock: Tool call IDs incompatible with Mistral models - "must be a-z, A-Z, 0-9, with a length of 9" · Issue #11802 · vercel/ai

[Bug] @ai-sdk/amazon-bedrock: Tool call IDs incompatible with Mistral models - "must be a-z, A-Z, 0-9, with a length of 9" #11802

New issue
Copy link
New issue
Copy link
Closed
Bug
#11863
Closed
[Bug] @ai-sdk/amazon-bedrock: Tool call IDs incompatible with Mistral models - "must be a-z, A-Z, 0-9, with a length of 9"#11802
Bug
#11863
Copy link
Assignees
aayush-kapoor
Labels
ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelmerged-mainprovider/amazon-bedrockIssues related to the @ai-sdk/amazon-bedrock providersupporttask-identify-issue-type-done

Description

@arpanpal-at
arpanpal-at
opened on Jan 15, 2026
Issue body actions

Description

When using Mistral models via @ai-sdk/amazon-bedrock, tool calling fails on multi-turn conversations because the tool call IDs generated by the Bedrock Converse API do not meet Mistral's strict format requirements.

Code to reproduce:

import {createAmazonBedrock} from '@ai-sdk/amazon-bedrock';
import {generateText, jsonSchema} from 'ai';

const bedrock = createAmazonBedrock({
    region: 'us-east-1',
    // ... credentials
});

const model = bedrock('mistral.ministral-3-14b-instruct');

const result = await generateText({
    model,
    tools: {
        searchWeb: {
            description: 'Search the web for information',
            parameters: jsonSchema({
                type: 'object',
                properties: {
                    query: {type: 'string', description: 'Search query'},
                },
                required: ['query'],
            }),
        },
    },
    toolChoice: 'auto',
    messages: [
        {
            role: 'user',
            content: 'Search for the projected revenue for Alphabet Inc. in 2026',
        },
    ],
    maxRetries: 1,
});

Expected Behavior

Tool calling should work correctly with Mistral models on Bedrock, similar to how it works with Anthropic models on Bedrock.

Actual Behavior

The first tool call succeeds, but when sending the tool result back for the next turn, the request fails with:

ValidationException: The model returned the following errors:
{
  "code": "validation_error",
  "message": "Tool call id was i-nKGDr5g but must be a-z, A-Z, 0-9, with a length of 9.
              Tool call id was i-nKGDr5g but must be a-z, A-Z, 0-9, with a length of 9.",
  "param": null,
  "type": "invalid_request_error"
}

Root Cause Analysis

  1. Bedrock generates tool call IDs in its own format: tooluse_bpe71yCfRu2b5i-nKGDr5g
  2. Mistral requires tool call IDs to match the regex ^[a-zA-Z0-9]{9}$:
    • Exactly 9 characters
    • Alphanumeric only (no underscores, hyphens, or prefixes)
  3. When the tool result is sent back with the Bedrock-format ID, Mistral's validation rejects it

Related Issues

This is a known compatibility issue that has been addressed in other projects:

  • opencode #1680 - Fixed via PR #2440
  • https://huggingface.co/spaces/arterm-sedov/cmw-copilot/blob/main/docs/MISTRAL_TOOL_CALL_ID_FIX.md

Suggested Fix

Add Mistral-specific tool call ID normalization in @ai-sdk/amazon-bedrock. The opencode project implemented this via a normalizeMistralToolCallIds() function that:

  1. Detects Mistral models by provider/model ID
  2. Transforms tool call IDs to meet Mistral's requirements (first 9 alphanumeric characters)

Example transformation:

  • tooluse_bpe71yCfRu2b5i-nKGDr5g → bpe71yCfR (9 alphanumeric chars)

Workaround

Currently, there is no workaround other than avoiding tool use with Mistral models on Bedrock, or implementing a custom transformation layer at the application level.

Additional Context

Full error response from Bedrock:

{
  "statusCode": 400,
  "responseHeaders": {
    "x-amzn-errortype": "ValidationException:http://internal.amazon.com/coral/com.amazon.bedrock/",
    "x-amzn-requestid": "1db5f47e-7335-4051-bea0-224852765024"
  },
  "responseBody": {
    "message": "The model returned the following errors: {\"code\":\"validation_error\",\"message\":\"Tool call id was i-nKGDr5g but must be a-z, A-Z, 0-9, with a length of 9.\"}"
  }
}

AI SDK Version

Environment:

  • ai: 5.0.27
  • @ai-sdk/amazon-bedrock: 3.0.19
  • Node.js: 20.x
  • AWS Region: us-east-1

Mistral models affected:

  • mistral.mistral-large-2407-v1:0
  • mistral.ministral-3-14b-instruct
  • mistral.ministral-3-8b-instruct

Code of Conduct

  • I agree to follow this project's Code of Conduct
Reacted by Heinrich Wendel

Activity

  1. arpanpal-at
    added
    support
    on Jan 15, 2026
  2. ghost added
    ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` label
    on Jan 15, 2026
  3. ghost added
    provider/amazon-bedrockIssues related to the @ai-sdk/amazon-bedrock provider
    on Jan 15, 2026
  4. aayush-kapoor
    self-assigned this
    on Jan 21, 2026
  5. aayush-kapoor
    added a commit that references this issue on Jan 21, 2026

    fix(amazon-bedrock): normalize tool call IDs for Mistral models (#11863)

    This issue will close once commit d5466df is merged into the 'main' branch.
    d5466df
  6. aayush-kapoor
    closed this as completedin #11863on Jan 21, 2026
  7. B-Step62
    added a commit that references this issue on Jan 28, 2026

    fix(amazon-bedrock): normalize tool call IDs for Mistral models (verc…

    This issue will close once commit 8ff7041 is merged into the 'main' branch.
    8ff7041
  8. lgrammel
    added
    merged-main
    on Jul 13, 2026
  9. lgrammel commented on Jul 22, 2026

    @lgrammel
    lgrammel
    on Jul 22, 2026
    Collaborator
    More actions

    Identify issue type

    Identified as Bug
    Confidence: High

    Rationale

    This is a concrete failure of existing Bedrock tool-calling behavior for supported Mistral models, not merely a request for new capability. The suggested normalization is a proposed fix for that incompatibility.

    Evidence

    • Multi-turn tool calling with Mistral models through @ai-sdk/amazon-bedrock fails with a Bedrock ValidationException.
    • Bedrock tool call IDs do not satisfy Mistral's required nine-character alphanumeric format when tool results are sent back.
    • The report includes reproducible code, affected package versions and models, the exact error, and expected versus actual behavior.
  10. lgrammel
    added the
    Bug
    issue type on Jul 22, 2026
  11. lgrammel
    added
    task-identify-issue-type-done
    on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @aayush-kapoor
    aayush-kapoor

Labels

ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelmerged-mainprovider/amazon-bedrockIssues related to the @ai-sdk/amazon-bedrock providersupporttask-identify-issue-type-done

Type

Bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402792 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.