refactor(anthropic): single-source the converted system note

The /v1/messages pass-through and the chat completions path must prefix a
converted system turn with the same operator note.
This commit is contained in:
Shifat Islam Santo 2026-08-23 19:44:25 -05:00
parent 986a505131
commit c79f3ac195

View file

@ -31,6 +31,7 @@ from ...common_utils import (
optionally_handle_anthropic_oauth,
strip_advisor_blocks_from_messages,
)
from ...mid_conversation_system import CONVERTED_SYSTEM_NOTE
DEFAULT_ANTHROPIC_API_VERSION: Final = "2023-06-01"
@ -160,9 +161,7 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):
def _is_system_role_message(message: Any) -> bool:
return isinstance(message, dict) and message.get("role") == "system"
_CONVERTED_SYSTEM_NOTE: Final = (
"Operator note (not from the user): the following was originally a mid-conversation system-role reminder."
)
_CONVERTED_SYSTEM_NOTE: Final = CONVERTED_SYSTEM_NOTE
def _system_role_message_as_user(self, message: Mapping) -> Mapping:
return {