Compare commits

...

3 Commits

Author SHA1 Message Date
lorenzejay
99c55d745f linted 2026-03-26 15:41:22 -07:00
lorenzejay
98725ed371 Merge branch 'main' of github.com:crewAIInc/crewAI into lorenze/imp/anthropic-prompt-caching 2026-03-26 15:41:00 -07:00
lorenzejay
2832834367 feat: enhance system message handling with prompt caching in AnthropicCompletion 2026-03-26 15:40:27 -07:00

View File

@@ -469,9 +469,15 @@ class AnthropicCompletion(BaseLLM):
"stream": self.stream,
}
# Add system message if present
# Add system message if present, with prompt caching
if system_message:
params["system"] = system_message
params["system"] = [
{
"type": "text",
"text": system_message,
"cache_control": {"type": "ephemeral"},
}
]
# Add optional parameters if set
if self.temperature is not None:
@@ -497,6 +503,9 @@ class AnthropicCompletion(BaseLLM):
if self.tool_search is not None and len(regular_tools) >= 2:
converted_tools = self._apply_tool_search(converted_tools)
if converted_tools:
converted_tools[-1]["cache_control"] = {"type": "ephemeral"}
params["tools"] = converted_tools
if available_functions and len(regular_tools) == 1: