Commit cc941d28 authored by Your Name's avatar Your Name

Implement Phase 1 Claude provider improvements

Add three key improvements to ClaudeProviderHandler based on comparison
with vendors/kilocode implementation:

1. Tool Call ID Sanitization (_sanitize_tool_call_id):
   - Replace invalid characters in tool call IDs with underscores
   - Claude API requires alphanumeric, underscore, hyphen only
   - Reference: vendors/kilocode normalizeMessages() sanitization

2. Empty Content Filtering (_filter_empty_content):
   - Filter out empty string messages and empty text parts
   - Claude API rejects messages with empty content
   - Reference: vendors/kilocode normalizeMessages() filtering

3. Prompt Caching (_apply_cache_control):
   - Apply ephemeral cache_control to last 2 messages
   - Enable Anthropic's prompt caching feature for cost savings
   - Reference: vendors/kilocode applyCaching()

All methods integrated into _convert_messages_to_anthropic() for
automatic application during message conversion.
parent 125f1647
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment