cd /news/ai-agents/claude-code-context-deep-dive-7-from… · home › topics › ai-agents › article
[ARTICLE · art-179881] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Claude Code Context Deep Dive (7): From System Reminders to Runtime Context

A developer's research note on Claude Code v2.1.220 details how the coding agent injects runtime context into model requests using `<system-reminder>` text blocks, covering date changes, external file edits, empty tool results, and newly available MCP servers or skills. The analysis shows these reminders are assembled just before a model call and grouped by trigger type—tool-adjacent, cadence-based, event-driven, and discovery—rather than by a single mechanism. It also notes that an internal `isMeta` marker, not an extra API role, distinguishes runtime metadata from user-authored text.

recommendation

Assemble runtime reminders at request time and tag them as metadata (e.g. an isMeta flag) so date changes, file edits and new tools reach the model without being mistaken for user input.

more in playbook: Designing agent systems
by read7 min views37 publishedDec 2, 2026

Editor's note: This is an AI-assisted English adaptation of a research note on Claude Code v2.1.220. The implementation observations describe that snapshot; links to the official docs distinguish them from supported behavior.

A long Claude Code session can span midnight. When you send your next message, the runtime can tell the model that the date changed. You didn't type that update. The model didn't infer it. It's information Claude Code supplied while preparing the next request.

The same problem shows up when a file changes outside the session, a tool reads an empty file, or an MCP server becomes available after the conversation has started. The model needs the new fact, but the user shouldn't have to say it. In the build examined here, Claude Code often carries those updates in text labeled <system-reminder>. The label is shared by several mechanisms. It isn't a feature with one trigger or one purpose.

Part 1 traces how Claude Code assembles a model request from the conversation. There's a difference between a message's API role and who produced the text inside it. The Messages API has a top-level system field and a messages array with user and assistant entries. A tool result goes into a user message without becoming something the human said. Runtime metadata can also travel in that part of the request. The snapshot described in Part 2 uses an internal isMeta marker to distinguish such content. That's a Claude Code implementation detail, not an extra API role.

A reminder can sit next to the evidence it describes. For example, a request could carry these two blocks in the same user turn. This illustrates the layout, not a claim that Claude Code always emits this exact payload:

{
  "role": "user",
  "content": [
    {
      "type": "tool_result",
      "tool_use_id": "toolu_example",
      "content": "Two documentation warnings."
    },
    {
      "type": "text",
      "text": "<system-reminder>The local date has changed.</system-reminder>"
    }
  ]
}

The API doesn't require a separate turn for every consecutive same-role entry. The Messages API reference says it combines adjacent entries of the same role into one turn. The tool-result rules are more specific: a client tool result follows the corresponding assistant tool call, and the result blocks go before any text in the following user message. Keeping nearby metadata together is useful because of what it describes, not because the API forbids two consecutive user entries.

Several reminders in the source snapshot were assembled just before a model call. That's a natural time to check what changed. You can be away from the terminal for five minutes without the model needing anything. When the next request goes out, a changed file or date becomes relevant. Some updates are driven by events; others are based on how much work the session has done since the last reminder. The fact that a notice enters the model's context at request time doesn't mean its producer discovered it at that exact moment.

The source grouped the examples by what put them into context, rather than treating their count or cadence as stable:

Update family What the next model call may need to know
Tool-adjacent A file was empty, the result covers only a range, or output needs to be interpreted cautiously.
Cadence-based Several turns have passed without a task-list update, so revisiting the plan may help.
Event-driven A file changed outside the session, the date rolled over, or diagnostics changed.
Discovery updates A skill or tool became available after the session started.
Project context Applicable project instructions or memory need to accompany the conversation.
Team or mode coordination A teammate sent an update or the operating mode changed.

The distinction matters when troubleshooting. If a status change is visible in the UI but hasn't reached the next request, the model can't act on it yet. Conversely, the model can receive a note without the UI displaying a new chat bubble. Context and notifications are separate concerns.

Part 3 showed why an early change can be expensive. Prompt caching matches the prefix of a request. If the beginning stays the same, an update later in the conversation can preserve an earlier cache hit. Rewriting the beginning to include every new fact would undermine that reuse.

The snapshot illustrates two ways to separate stable context from changing state. Startup environment text can describe where the session began, while tools operate on the current working directory. The prompt's earlier directory isn't a reliable answer to “where will this command run now?” Similarly, project instructions can be supplied as conversation context instead of being treated as permanent parts of the base prompt. See Part 5 on CLAUDE.md and Part 6 on subagents. Where an update lands matters, but neither using a reminder nor placing something in messages guarantees a cache hit. What matters is whether the cached prefix changed.

A file read can contain three different things: the requested content, context about how much was returned, and a note about how to treat that content. The snapshot also describes tracking recent reads and sometimes returning an unchanged-file notice instead of duplicating a prior result. The notice refers to earlier evidence; it isn't a fresh copy of the file. If that evidence is stale, missing, or outside the range you need, read the relevant range again before editing.

The Claude Code tools reference describes the supported read interface. Limits can depend on the input, and a returned excerpt doesn't establish what the rest of a file contains. The earlier Read tool deep dive covers the read-before-edit relationship in more detail.

File content is also untrusted data. A runtime reminder can make that distinction salient to the model, but it doesn't enforce permissions. Tool input validation, permission checks, and user approval for consequential actions belong at the execution boundary. The tag itself doesn't make a piece of text authoritative.

A skill name and description help the model decide whether a procedure is relevant. They don't have to carry the whole procedure. In a normal session, Claude Code's skills guide says the full skill content loads on invocation. Some skills are configured not to be invoked by the model. A subagent with preloaded skills is a separate case: it receives the content at startup.

This is just-in-time retrieval: provide enough information to choose, then load the detail for the work at hand. In the snapshot, the runtime could send additions to a skill listing without rebuilding it for every change. Compaction is a distinct boundary: when history is summarized, assuming that a previously delivered listing is still visible can lead to bad decisions. Part 4 covers that transition. The context window guide documents that Claude Code v2.1.304 and later rebuilds and reinjects skill descriptions after compaction. That's a separate claim from how older builds recorded which skills they'd already sent.

The same trade-off applies to tools. If a workspace has a large set of MCP tools, the agent doesn't necessarily need every schema on the first turn. Claude Code's MCP documentation describes tool definitions as they're discovered. When using ENABLE_TOOL_SEARCH=auto, the documented threshold is 10% of the context window for the definitions of tools that would otherwise be deferred. auto:N sets a custom percentage. That's a size threshold, not a chance that any given request will use tool search.

The Claude API's tool search feature is a separate interface. For custom tools marked with defer_, sending a definition in the request doesn't mean the full schema immediately enters the model's context. The schema becomes available when the tool is discovered and referenced. API clients shouldn't assume that the behavior of a particular Claude Code release is the contract for their own integration.

A server connecting late raises a different question: what should the model know about the new service? A short update can introduce that server's instructions without rewriting earlier conversation data. But that doesn't prove reconnecting is free from a cache perspective. Changing the definitions or another early part of the request can still change the cached prefix. Keep three questions separate: Is the server connected? Does the model have the instructions or schema it needs? Is the call authorized?

A system reminder tells the model something the runtime knows. It doesn't by itself send a notification, grant a tool permission, or decide what action should happen next. If you're tracing an unexpected action, look at where the event was detected, where it entered context, and what the executor actually allowed. Those are three different places to look for the cause.

The Agent Loop article on streaming offers the reverse perspective: how model and tool events make it back to the interface. The Agent Loop finale ties those execution decisions together. Part 8 will close this series by connecting the information flow to the execution loop: what stays stable, what gets compacted, and what arrives only when needed.

── more in #ai-agents 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/claude-code-context-…] indexed:0 read:7min 2026-12-02 · —