FeaturesMessagesMeta
Anthropic Special Flags
Store Anthropic-specific message flags like prompt caching and thinking blocks
Acontext preserves Anthropic-specific flags like cache_control for prompt caching and thinking blocks for extended thinking.
Prompt Cache
client.sessions.store_message(
session_id=session.id,
blob={
"role": "user",
"content": [
{
"type": "text",
"text": "<the entire contents of Pride and Prejudice>",
"cache_control": {"type": "ephemeral"}
}
]
},
format="anthropic"
)
# Retrieved messages preserve the cache_control flag
messages = client.sessions.get_messages(session_id=session.id, format="anthropic")await client.sessions.storeMessage(session.id, {
role: "user",
content: [
{
type: "text",
text: "<the entire contents of Pride and Prejudice>",
cache_control: { type: "ephemeral" }
}
]
}, { format: "anthropic" });
// Retrieved messages preserve the cache_control flag
const messages = await client.sessions.getMessages(session.id, { format: "anthropic" });Thinking Blocks
Acontext natively stores thinking blocks from Claude's extended thinking feature. The signature is preserved for multi-turn conversation continuity.
client.sessions.store_message(
session_id=session.id,
blob={
"role": "assistant",
"content": [
{
"type": "thinking",
"thinking": "Let me reason step by step...",
"signature": "EqoBCkgIAxgCIkD..."
},
{
"type": "text",
"text": "The answer is 42."
}
]
},
format="anthropic"
)
# Retrieved in Anthropic or Gemini format: thinking blocks round-trip as native thinking blocks
# Retrieved in OpenAI format: thinking content is downgraded to plain textawait client.sessions.storeMessage(session.id, {
role: "assistant",
content: [
{
type: "thinking",
thinking: "Let me reason step by step...",
signature: "EqoBCkgIAxgCIkD..."
},
{
type: "text",
text: "The answer is 42."
}
]
}, { format: "anthropic" });
// Retrieved in Anthropic or Gemini format: thinking blocks round-trip as native thinking blocks
// Retrieved in OpenAI format: thinking content is downgraded to plain textIf you're using the Claude Agent SDK, see ClaudeAgentStorage for automatic thinking block handling.
Last updated on