Mahal Systems

Overview › 3Prompts › a.Structuring › iii.

Dynamic context injection

PromptContext General

Put the runtime facts the model cannot know into its context each run: today's date and timezone, the working directory, OS and git state, the tools available, the user and locale. Inject them after the cached prefix, as a date rather than a timestamp, and refresh them when they change. The measured gains are on time-sensitive work: absolute dates beat relative ones, and stating the time remaining each turn raised deal closure under deadlines. On tasks that do not depend on time, the date only adds variance.

Tier 3 because it changes what the model sees.

When it applies

  • In the code: Prompt templates contain runtime placeholders (date, time, user, locale, tool availability). Absence where tasks are time- or user-sensitive is the signal.
  • In traces: Model guesses the date or year, asks the user for information the system already has, builds queries with stale dates.
  • In eval results: Failures concentrated on time-sensitive or user-specific items.
  • With a judge: Flag outputs that assume stale state.
  • With probes: Tasks whose answer depends on today's date, relative dates, locale or the current user.

How

  1. List the runtime facts your tasks depend on: date and IANA timezone, working directory, OS and shell, git status, the tools or skills available, the user and locale.
  2. Inject them after the cached prefix, in a trailing block or a message in the conversation, never under a cache breakpoint; keep the date to the day, and serve time of day through a clock tool or the shell.
  3. State dates as absolute values, and resolve relative dates ("last quarter") to absolute ones before the model sees them.
  4. Refresh on change: resend the block when a value changes and after compaction or resume; if the run has a deadline, inject the time remaining each turn.
  5. Fix the date in evals and report it; run a time-sensitive slice with and without the injection, and watch cache-read tokens.

How to measure it

  • before after (tier 3): run a time-sensitive slice with and without the injected block, with the date fixed; compare cache-read tokens per call before and after
  • monitor: questions asking the user for facts the system holds, date errors in outputs, cache-hit rate

To compare the change against your agent's current version, with the same cases and enough repeats to see past run-to-run noise, use aot-evals.

Expected impact

  • Quality: mixed, medium: time-sensitive work: deal closure 0.04 to 0.32 with the time remaining stated each turn (Sehgal, Jan 2026); answers 24-35% worse with relative than with absolute dates (Wallat, 2024). On tasks that do not depend on time, the date moved scores by up to 14% with no good date to fix (Sanz-Guerrero, Sep 2026)
  • Cost: none: if the block sits after the cached prefix; a date in the system prompt cost Claude Code cache hits until it was moved out (Feb 2026)
  • Performance: none
  • Security: mixed, small (unmeasured): Injected state is a small injection surface.
  • Governance: mixed, small (unmeasured): User data in the prompt needs retention rules.
  • Brand: improves, small (unmeasured): Fewer obviously wrong dates.

Caveats

Few studies isolate the date on agent tasks; the measured support is indirect: a stated year, absolute against relative dates, the time remaining in a negotiation. On tasks that do not depend on time the date only adds variance, and chain-of-thought amplifies it, so fix the date in evals. Some providers already add a date server-side, so check the model is not seeing two. Any per-request value placed before the cached prefix turns every call into a cache write (3.b.i).

Evidence

Evidence comes from: Conversation, Reasoning, Code generation.

  1. Lists this practice in its agent-optimization pattern library (Context Engineering group)Not measured

    Names the practice as a known agent optimization; reports no measured effect for it.

    Scale AI, "VeRO: A Harness for Agents to Optimize Agents" (ICML 2026) · Feb 2026 · paper Table 6; pattern library file master-agent-optimization-cookbook.md

  2. Anthropic injects runtime state such as the current date into the system prompt of its own appsNot measured

    Claude's web and mobile apps "use a system prompt to provide up-to-date information, such as the current date, to Claude at the start of every conversation."

    Anthropic, "System Prompts" (release notes) · Page intro

  3. State the reference year in the prompt ("As of year 2022") for time-sensitive questions

    F1 on questions about 2022 rose from 17.2 to 24.4 with the year in a 5-shot prompt. The authors also note that "prompting LMs to be aligned to a more recent year could lead to more QA errors."

    Zhao, Brumbaugh, Wang, Hajishirzi, Smith, "Set the Clock: Temporal Alignment of Pretrained Language Models" · Feb 2024Older evidence · App. A, Table 6

  4. Ask with relative time references ("3 years ago") instead of absolute years

    Performance dropped 24-35% for text-davinci-003 and 23-30% for alpaca-7B with relative references; both models answered 2021 when asked what year it is.

    Wallat, Jatowt, Anand, "Temporal Blind Spots in Large Language Models" · Jan 2024Older evidence · Figure 2 and surrounding text

  5. Inject the time remaining into each turn of deadline-bound negotiations between agents

    Deal closure rose from 0.04 (12/300) to 0.32 (97/300) for GPT-5.1; offers were over six times more likely to be accepted (OR = 6.38). GPT-4.1 went from 44.7% to 72.0%. "only 5 of 10 comparisons reach Bonferroni-corrected significance."

    Sehgal, Guntuku, Ungar, "Real-Time Deadlines Reveal Fragile Temporal Adaptation in LLM Strategic Dialogues" · Jan 2026 · Figure 2; Table 2

  6. Vary the current date in the system prompt on benchmarks that do not depend on timeMixed

    Performance "varies solely with the current date, with deltas of up to 6% on MCQA, 14% on math reasoning, 7% on code generation, and 2.84 BLEU"; "chain-of-thought even amplifies it". With no date, scores fall within the range seen across dates: the date adds variance, and there is no good date to fix.

    Sanz-Guerrero, Bui, Mager, von der Wense, "Dating the Model: Hidden Dates in System Prompts Affect LLM Evaluation" · Sep 2026 · Abstract; Table 3; App. B

  7. Inject environment, OS and git state into the promptNot measured

    Mini-SWE-Agent template "includes OS-specific instructions (e.g., sed -i '' for macOS)"; Mistral Vibe Git context block "(output of git log --oneline -N --decorate and git status --porcelain, cached)"; Hermes keeps "a date-only timestamp" so the prefix stays byte-identical.

    Barbaste et al., "Harness Engineering: Anatomy, Architecture, and Evolution of Coding Agents -- A Source-Code Study of Eleven Systems" · Jul 2026 · Sec 7.2

  8. Move the date out of the system promptNot measured

    "Improved prompt cache hit rates by moving date out of system prompt." No numbers.

    Anthropic, Claude Code changelog, version 2.1.42 · Feb 2026 · Version 2.1.42

  9. Add the local date and IANA timezone to the per-turn environment contextNot measured

    Adds current_date and timezone to the environment_context block and "treats date/timezone changes as environment updates, so prompt caching and context refresh logic do not silently reuse stale time context."

    OpenAI Codex CLI, "feat: add local date/timezone to turn environment context" · Feb 2026 · PR description

Related

In Claude Code

This optimization is a skill in aot-kit, our open-source Claude Code plugin: /aot-kit:inject-runtime-context. Its library entry holds every source. Have new evidence, or a correction? Suggest a change.

Before you go...

Build better agents, weekly

Our latest research, performance benchmarks, optimization strategies, and updates around AOT development.

One email a week, nothing else. Unsubscribe anytime.