Giving Claude a Rule for Just One Turn: A Working Example With clear_at

A sand hourglass timer standing upright

Claude’s API accepts a message with role: "system" and clear_at: "next_user_message" that applies for exactly the current turn and is cleared automatically, at no token cost, as soon as the next user message arrives. It is documented under the beta header mid-conversation-system-clear-at-2026-08-21, and it exists for exactly the case where you want to steer one reply — “keep this under 50 words,” say — without permanently rewriting the top-level system prompt that governs the rest of the conversation.

Why not just edit the top-level system prompt?

You could, but editing or removing a previously sent system message invalidates the prompt cache from that point forward, and on Claude 5.1-generation models it also invalidates thinking blocks in every later assistant turn. A turn-scoped message sidesteps that: appending a new message after your cache breakpoint leaves the cached prefix untouched, so the cache still hits even though a one-off instruction got added. The trade-off is that a turn-scoped message cannot itself carry cache_control — you get the cache-safety benefit precisely because the turn-scoped content is never part of what gets cached.

The request, field by field

Here is a complete, working example — a status update bot that normally writes freely, but needs one reply kept short because the reader is on call:

response = client.beta.messages.create(
    model="claude-fable-5-1",
    max_tokens=4096,
    messages=[
        {"role": "user", "content": "Draft a short status update on the database migration for the team channel."},
        {"role": "system", "clear_at": "next_user_message",
         "content": "The reader is on call: keep this reply under 50 words."},
    ],
    betas=["mid-conversation-system-clear-at-2026-08-21"],
)
  • betas=["mid-conversation-system-clear-at-2026-08-21"] — without this exact beta string, the clear_at field is rejected outright as an unknown input. This is the one line most people forget, since the rest of the request looks like an ordinary system message.
  • {"role": "system", ...} as an entry inside messages, not the top-level system parameter. The two are different fields entirely; a turn-scoped instruction only works as a message-array entry.
  • clear_at: "next_user_message" — the only other valid value is "never", which is also the default if you omit the field, and behaves like an ordinary permanent system message instead.
  • Placement: immediately after the user turn it should affect, and either last in the array or followed by an assistant turn. Here it sits right after the single user message, so it governs the very next reply and nothing after that.
  • Content is text-only for a turn-scoped message — no images, no tool blocks, and no cache_control. Anything beyond plain text on this specific message type returns a 400.

Once the model answers, that message is done: it stays in your stored messages array for your own records, but it renders nothing on the next request and costs no input tokens from that point on. If you send another user message after this one, you do not need to remove the turn-scoped entry yourself — the API treats it as already cleared.

Placement rules you will actually hit

A handful of validation rules show up often enough in practice to list directly, since violating any of them returns a flat 400 rather than a helpful retry: the message cannot be the first entry in messages (use the top-level system field for anything that needs to apply from the start); it must immediately follow a user turn, including one that only contains tool_result blocks; and it cannot sit between an assistant tool_use block and that call’s matching tool_result. For an agent running a client-side tool loop, that last rule means you append a fresh turn-scoped message after each tool_result message if you want the reminder to keep applying turn by turn, rather than attaching it once and expecting it to survive a tool round-trip.

How it interacts with prompt caching

Anthropic’s own documentation is specific that the cache hash order is tools, then system, then messages. A turn-scoped message lives inside messages, after whatever breakpoint you set earlier, so appending one does not retroactively invalidate anything before it. This is a sharper tool for the same underlying problem our working example of prompt caching breakpoints walks through: keeping a long, expensive-to-recompute prefix stable while something later in the conversation still needs to change.

When to reach for this instead of the alternatives

A turn-scoped system message is the right tool specifically when the instruction is genuinely temporary and the alternative is editing a prompt you would then have to remember to edit back. If what you actually need is to prune old tool results out of a long-running agent loop to save context, that is a different, already-documented mechanism covered in our breakdown of context editing’s clear_tool_uses parameter. If you need the model to remember something across many future conversations rather than for one turn, that is what Claude’s memory tool is for instead. And if your “one-off instruction” is really a scoped permission change for a subagent rather than a steering note for the main model, that overlaps more with setting up Claude Agent SDK subagents with tool restrictions than with anything in this article.

Errors you will see if you get it wrong

messages.3.clear_at: Extra inputs are not permitted
messages.3.clear_at: clear_at is only permitted on role 'system' messages
messages.3.clear_at: Input should be 'next_user_message' or 'never'
messages.3: a turn-scoped system message supports text blocks only (clear_at: 'next_user_message')

The first of those four is the one that catches almost everyone on a first attempt: it means the beta header was left off the request entirely, not that clear_at itself is malformed.

Photo: hourglass by Thamizhpparithi Maari, Wikimedia Commons, CC BY-SA 3.0.

The same message type can also add or remove tools mid-conversation

Turn-scoped messages are the narrowest case of a broader mechanism: a role: "system" message placed mid-conversation can also carry tool_addition or tool_removal content blocks, under a different beta header, inline-tools-2026-09-15. Unlike the turn-scoped case, these persist beyond the next user message — they are not paired with clear_at at all, since the point is to permanently change which tools are offered partway through a long conversation, not to apply a one-turn reminder. A tool removed this way can be re-offered later with a matching tool_addition block that references it by name.

{
  "role": "system",
  "content": [
    {
      "type": "tool_removal",
      "tool": {"type": "tool_reference", "name": "get_weather"}
    }
  ]
}

That block withdraws the get_weather tool from everything the model is offered from this point forward in the conversation, without touching anything already cached before it. The same content-block family also supports defining a brand-new tool by value mid-conversation, or wiring in a whole MCP server’s toolset on the fly, both gated behind the same beta flag. None of that overlaps with clear_at, which only ever carries plain text.

Frequently asked

Can I combine a turn-scoped reminder and a tool change in the same request? Yes, as long as they are on separate system-message entries with their own correct fields — a clear_at message stays text-only and cannot carry a tool_addition or tool_removal block itself, so do not try to merge the two into one message.

Does a turn-scoped message work the same way on every model? No. The feature is not available on Claude Sonnet 5, which the documentation says should use the top-level system field instead; it is documented as supported on Fable 5.1, Mythos 5.1, Fable 5, Mythos 5, Opus 5.5, Opus 4.8, Opus 5, Sonnet 5.5, and Haiku 5.5.

Does Managed Agents support this the same way? No — Managed Agents use a different mechanism entirely, a system.message event that applies to that turn and every later turn in the session, with no equivalent of clear_at to expire it automatically. The agent’s own top-level system field also cannot change mid-session on that surface.

What happens if I resend a turn-scoped message with slightly different wording on a later request? Treat that as an edit to earlier history, which invalidates the cache from that point forward the same way editing any other prior message would — the documentation is explicit that a turn-scoped message must be resent verbatim, not rebuilt, if it needs to appear again in a later request for any reason.

One more limit worth knowing before you reach for this in an agentic loop: assistant turns, whether prefilled or paused on a server-side tool result, do not clear a turn-scoped message on their own. If your loop is driven by client-side tools rather than server-side ones, that means you need to append a fresh copy of the reminder after each tool_result message yourself if you want it to keep applying across every step of the loop, rather than assuming one turn-scoped message set early on will keep steering every later tool call until a real user message finally arrives.

As with any beta header, confirm current availability against Anthropic’s own API reference before shipping this in production, since beta features can graduate to general availability, change shape, or pick up new restrictions between when an article like this one is written and when you read it.

That one-sentence caveat matters more for a feature like this than for most, precisely because it is still in beta.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top