Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Feb 11, 2026

Reverts #11386

Important

Migrated the entire codebase from custom RooMessage types to Anthropic SDK message types, replacing dual-format message handling with direct Anthropic.Messages.MessageParam usage and introducing a centralized convertToAiSdkMessages function for message conversion.

Message Type Migration

  • Type System Overhaul: Replaced custom RooMessage type with Anthropic.Messages.MessageParam throughout the codebase, removing dual-format message handling that supported both AI SDK and legacy Anthropic formats.
  • Removed Custom Types: Eliminated RooMessage, RooRoleMessage, UserContentPart, ContentBlockParam, LegacyToolUseBlock, LegacyToolResultBlock, AnyToolCallBlock, and AnyToolResultBlock type definitions and their associated helper functions from task-persistence module.
  • Centralized Message Conversion: Introduced convertToAiSdkMessages function as the single point for converting messages to AI SDK format, replacing scattered type assertions across provider implementations.

Tool Block Format Changes

  • Tool Call Blocks: Changed from custom "tool-call" type with toolCallId/toolName properties to Anthropic "tool_use" type with id/name properties.
  • Tool Result Blocks: Changed from custom "tool-result" type with toolCallId/output structure to Anthropic "tool_result" type with tool_use_id/content properties and is_error boolean.
  • Image Blocks: Updated image structure from flat format with image and mimeType properties to nested source object with type, data, and media_type properties.

Provider Updates

  • All Provider Classes (anthropic.ts, azure.ts, bedrock.ts, openai.ts, gemini.ts, ... and 20+ others): Updated createMessage method signatures to accept Anthropic.Messages.MessageParam[] instead of RooMessage[], replaced direct type casting with convertToAiSdkMessages function calls.
  • Cache Control Methods: Updated applyCacheControlToAiSdkMessages and applyCachePointsToAiSdkMessages methods in Anthropic and Bedrock providers to accept original messages and properly map cache control to converted AI SDK messages.
  • Message Filtering: Simplified message filtering logic by removing custom type guards and using direct Anthropic type checks.

Core Message Processing

  • Task.ts: Replaced pendingToolResults array with direct storage in userMessageContent array, updated pushToolResultToUserContent to work with Anthropic.ToolResultBlockParam, changed apiConversationHistory type from RooMessage[] to ApiMessage[].
  • Message Merging: Updated mergeConsecutiveApiMessages.ts to work directly with Anthropic types, removed special handling for RooReasoningMessage.
  • Tool Result Validation: Refactored validateToolResultIds.ts to use Anthropic SDK types directly, replaced helper function calls with direct property access.
  • Condense Logic: Updated condense/index.ts to work with ApiMessage and Anthropic block types, simplified tool block processing by removing helper functions.

Message Content Processing

  • Image Cleaning: Updated image-cleaning.ts to use ApiMessage type and work with Anthropic image block format.
  • OpenAI Format Conversion: Completely refactored openai-format.ts to accept Anthropic.Messages.MessageParam[] instead of RooMessage[], removed legacy format handling, simplified message processing logic.
  • User Content Mentions: Updated processUserContentMentions.ts to handle Anthropic.Messages.ContentBlockParam[] and added comprehensive support for tool_result blocks with both string and array content.
  • Response Formatting: Updated responses.ts to return Anthropic SDK types (Anthropic.TextBlockParam, Anthropic.ImageBlockParam) instead of custom types.

Test Updates

  • Provider Tests: Updated 25+ provider test files to use Anthropic.Messages.MessageParam[] type annotations instead of RooMessage[], updated test data structures to match Anthropic SDK format.
  • Core Tests: Updated tests in condense, context-management, task, and assistant-message modules to use ApiMessage type and Anthropic block format, removed type assertions where proper typing is now available.
  • Tool Result Tests: Updated test data to use tool_result type with tool_use_id and content properties instead of custom format.

Type Safety Improvements

  • Removed Type Assertions: Eliminated numerous as any type assertions throughout the codebase by using proper Anthropic SDK types.
  • Improved Type Inference: Replaced explicit type casts with TypeScript's type inference where types are now properly defined.
  • Better Type Guards: Simplified type checking by using direct property access and Anthropic SDK type checks instead of custom helper functions.

This description was created by Ellipsis for 0577a12. You can customize this summary. It will automatically update as commits are pushed.

@linear
Copy link

linear bot commented Feb 11, 2026

Issue reopened: EXT-647 Implement ModelMessage storage layer

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 11, 2026
@mrubens mrubens merged commit dcb33c4 into main Feb 11, 2026
13 checks passed
@mrubens mrubens deleted the revert-11386-feature/ext-647-implement-modelmessage-storage-layer branch February 11, 2026 04:57
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 11, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 11, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 11, 2026

Rooviewer Clock   Follow task

Reviewing your PR now. Feedback coming shortly!

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

Labels

lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants