Roo-Code/src/core/task
Roo Code dfaf0e8353 fix: add pre-send validation for tool_use/tool_result pairing (#11777)
Adds validateMessageHistoryBeforeSend() as a safety net that runs on the
final message array right before the API call. This catches any
tool_use blocks that are missing corresponding tool_result blocks -
a mismatch that causes Anthropic API rejection.

The validation:
- Iterates through the final messages looking for assistant messages
  with tool_use blocks
- Checks the following user message has matching tool_result blocks
- Injects placeholder tool_results for any missing pairings
- Inserts synthetic user messages when none follow an assistant message
- Reports mismatches to telemetry via MissingToolResultError

This addresses cases where post-processing steps (getEffectiveApiHistory,
mergeConsecutiveApiMessages, buildCleanConversationHistory) may
introduce mismatches after the existing insert-time validation.
2026-04-24 17:37:08 +00:00
..
__tests__ fix: add pre-send validation for tool_use/tool_result pairing (#11777) 2026-04-24 17:37:08 +00:00
AskIgnoredError.ts fix: suppress 'ask promise was ignored' error in handleError (#9914) 2025-12-08 17:19:45 -08:00
build-tools.ts Reapply Batches 3-4: Skills, browser removal, provider removals (6 major-conflict cherry-picks) (#11475) 2026-02-14 22:06:24 -07:00
mergeConsecutiveApiMessages.ts Revert to pre-AI-SDK state (January 29, 2026) (#11462) 2026-02-13 16:45:18 -05:00
Task.ts fix: add pre-send validation for tool_use/tool_result pairing (#11777) 2026-04-24 17:37:08 +00:00
validateToolResultIds.ts fix: add pre-send validation for tool_use/tool_result pairing (#11777) 2026-04-24 17:37:08 +00:00