Skip to content

Comments

Bug fix: don't add an empty user prompt in multi-tool use scenarios#38

Merged
tonybaloney merged 1 commit intotonybaloney:mainfrom
cmbrose:cmbrose/multi-tool-fix
Jun 2, 2025
Merged

Bug fix: don't add an empty user prompt in multi-tool use scenarios#38
tonybaloney merged 1 commit intotonybaloney:mainfrom
cmbrose:cmbrose/multi-tool-fix

Conversation

@cmbrose
Copy link
Contributor

@cmbrose cmbrose commented May 30, 2025

The API expects tool_call messages to be immediately followed by their results.

However, there's a bug in the previous message rebuilding logic that will accidentally insert an empty user prompt message which breaks this rule and causes an error like

Error: (None) An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_EsQHgm5PGNvnvuVVh3tvvaEr
Code: None
Message: An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_EsQHgm5PGNvnvuVVh3tvvaEr

This bug only appears if the for cases where we're doing multiple rounds of tool calls and prompts which is why it was missed originally. Added a test to handle multiple tool calls and confirmed that the bug repro'd before and is gone after.

@tonybaloney tonybaloney merged commit 6c8f81a into tonybaloney:main Jun 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants