AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

ChatAnthropic Silently Drops Message-Level Output_config And Clear_at From SystemMessage

ChatAnthropic's message serialization for SystemMessage does not preserve additional_kwargs such as output_config and clear_at. This causes per-message effort changes to be silently ignored and turn-scoped instructions to become persistent across later turns. Claude Sonnet 5.5 is also not recognized by the message-level system message capability check.

highConfidence 90%Langchain-AnthropicAffected V<=1.7.4

Origin Analysis

The _format_messages method in ChatAnthropic only copies message.role and message.content when serializing SystemMessage, ignoring message.additional_kwargs. For an empty SystemMessage with only output_config, the serialized message may be omitted entirely. Additionally, the model capability check for mid-conversation system messages does not include claude-sonnet-5-5, causing that model to fall back to top-level system hoisting.
1. Create ChatAnthropic(model='claude-opus-5'). 2. Pass [SystemMessage([], additional_kwargs={'output_config': {'effort': 'low'}}), HumanMessage('Plan a migration.')] to _get_request_payload or invoke. 3. Observe output_config is absent from the request messages. 4. Pass [HumanMessage('Write a status update.'), SystemMessage('Keep the response under 50 words.', additional_kwargs={'clear_at': 'next_user_message'})]. 5. Observe clear_at is absent from the serialized system message. 6. With model='claude-sonnet-5-5', observe the system message is hoisted to top-level system rather than kept in messages.

Fixing Code Block

Edge Case Audit

Preserving these fields may expose Anthropic API validation errors: adjacent system messages must be validated as a group, and turn-scoped messages cannot contain tool_addition, tool_removal, output_config, or cached text blocks. The current fix does not implement local validation for these combinations; invalid payloads may be rejected by the API. For non-direct transports like Bedrock, cache_control post-processing must skip turn-scoped system messages to avoid attaching breakpoints to them. Additionally, the beta headers mid-conversation-output-config-2026-07-01 and mid-conversation-system-clear-at-2026-08-21 must be present; otherwise the API will reject the request. If issues arise after deployment, rollback by pinning langchain-anthropic==1.7.4 and avoiding these message-level fields. Monitor for model-specific support and update _supports_message_level_system.

Ecosystem Topology