# Anthropic Special Flags



Acontext preserves Anthropic-specific flags like `cache_control` for [prompt caching](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching) and `thinking` blocks for [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking).

## Prompt Cache [#prompt-cache]

<CodeGroup>
  ```python title="Python"
  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")
  ```

  ```typescript title="TypeScript"
  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" });
  ```
</CodeGroup>

## Thinking Blocks [#thinking-blocks]

Acontext natively stores `thinking` blocks from Claude's extended thinking feature. The `signature` is preserved for multi-turn conversation continuity.

<CodeGroup>
  ```python title="Python"
  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 text
  ```

  ```typescript title="TypeScript"
  await 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 text
  ```
</CodeGroup>

<Tip>
  If you're using the Claude Agent SDK, see [ClaudeAgentStorage](/integrations/claude-agent#include-thinking-blocks) for automatic thinking block handling.
</Tip>
