mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-23 00:43:14 +00:00
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. |
||
|---|---|---|
| .. | ||
| __tests__ | ||
| AskIgnoredError.ts | ||
| build-tools.ts | ||
| mergeConsecutiveApiMessages.ts | ||
| Task.ts | ||
| validateToolResultIds.ts | ||