Skip to content

Fix missing tool_result blocks in AI messages #1761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Fix missing tool_result blocks in AI messages

This PR adds validation and automatic fixing of AI messages where tool_use blocks don't have corresponding tool_result blocks immediately after them. This resolves the error: "messages.1: tool_use ids were found without tool_result blocks immediately after".

Changes

  • Added a new validateAndFixToolMessages method to the ChatConversationImpl class in both studio and web client
  • The method checks each assistant message for tool calls and ensures they have corresponding tool results
  • If a tool call is missing its result, a stub tool_result message is created with an empty result object and isError flag
  • Added console warnings when stub tool results are automatically created
  • Implemented in both the studio app and web client for consistency

Testing

The changes have been tested to ensure they properly identify and fix missing tool_result messages.

Link to Devin run: https://app.devin.ai/sessions/53cefc79f3894347853c2b872ac2c908
Requested by: [email protected]

@Kitenite Kitenite merged commit 379355c into main Apr 9, 2025
@Kitenite Kitenite deleted the devin/1744179966-fix-missing-tool-results branch April 9, 2025 06:47
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

3 similar comments
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

ml-delaurier pushed a commit to ml-delaurier/nolook that referenced this pull request Apr 23, 2025
* Fix missing tool_result blocks in AI messages

* Update stub tool_result to use success string and add error logging

* Add try catch

* Clean up

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Kiet Ho <[email protected]>
t1c1 pushed a commit to t1c1/onlookbotcodes that referenced this pull request Jun 5, 2025
* Fix missing tool_result blocks in AI messages

* Update stub tool_result to use success string and add error logging

* Add try catch

* Clean up

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Kiet Ho <[email protected]>
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.

1 participant