Skip to content

fix(litellm): generate toolUseId when missing from provider#2949

Open
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1259-litellm-tool-id
Open

fix(litellm): generate toolUseId when missing from provider#2949
chaynabors wants to merge 1 commit into
strands-agents:mainfrom
chaynabors:agent-tasks/1259-litellm-tool-id

Conversation

@chaynabors

Copy link
Copy Markdown
Member

Supersedes #1262 with a clean rebase on current main.

LiteLLM returns null for the tool call id field on some providers, leaving toolUseId as None in the resulting event stream. The fix assigns a fresh call_ when the first tool delta arrives without an id, before the content_start chunk, so downstream consumers see a stable identifier. Behavior is unchanged whenever a provider supplies an id.

Refs #1262, fixes #1259.

@github-actions github-actions Bot added size/s python Pull requests that update python code area-model Related to models or model providers area-tool Tool behavior/api bug Something isn't working labels Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

yield self.format_chunk({"chunk_type": "content_start", "data_type": "tool", "data": tool_deltas[0]})
first_delta = tool_deltas[0]
if not first_delta.id:
first_delta.id = f"call_{uuid.uuid4()}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it fixes the tool_use side of the id, but how does the tool result get associated with the same tool use id? Do we have to pair up the tool result with the generated id? I'm a little concerned we're just trading one problem for another

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-model Related to models or model providers area-tool Tool behavior/api bug Something isn't working python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Strands providing null value in id field of tool_calls

3 participants