Skip to content

[BUG] Wrong toolUseId when using gemini-2.5-flash #1200

@AirswitchAsa

Description

@AirswitchAsa

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.17.0

Python Version

3.13.2

Operating System

MacOS 15.6.1 (24G90)

Installation Method

pip

Steps to Reproduce

  1. have environment set up. I have an example here
  2. run the following script
import asyncio
import random

from strands import Agent, tool
from strands.models.gemini import GeminiModel

model: GeminiModel = GeminiModel(
    client_args={"api_key": os.getenv("GOOGLE_AI_API_KEY")},
    model_id="gemini-2.5-flash",
)


@tool
async def call_api() -> str:
    """Call API asynchronously."""

    await asyncio.sleep(3)  # simulated api call
    return f"API result: {random.randint(1, 1000)}"

agent = Agent(tools=[call_api], model=model, callback_handler=None, name="gemini_agent")

# Async function that iterators over streamed agent events
async def process_streaming_response(agent: Agent) -> None:
    agent_stream = agent.stream_async("Can you call my API twice?")
    print(f"Starting to stream events for {agent.name}")
    async for event in agent_stream:
        print(event)
    print(f"Finished streaming events for {agent.name}")


asyncio.run(process_streaming_response(agent))

Expected Behavior

unique toolUseId named in the format tooluse_{identifier}

Actual Behavior

call_api being shown as the toolUseId instead of something like tooluse_{identifier}, like below:

{"message": {"role": "assistant", "content": [{"toolUse": {"toolUseId": "call_api", "name": "call_api", "input": {}}}]}}

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions