Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent workflows

Prewarm research context while the user types

When a user begins composing a query, send a one-token request with the same large context to hide cache-creation latency.

Goal

Reduce time to first token when large research context is reused.

Steps

  1. When the user focuses the input or starts typing, issue a background one-token cache-warming request using the same context that will be submitted. [source13]
  2. After submission, send the real request and inspect cache_read_input_tokens; keep the warm-up and final context identical and scoped to the same session. [source13]
  3. Compare TTFT and cost with ordinary caching; stop warming after an idle timeout and never share private context across users. [source13]

How to verify

The real request records a cache read for the same large context, reduces TTFT against the cold baseline, and shows no cross-user data reuse.

Troubleshooting

If there is no cache hit, compare the warm-up and final context byte-for-byte and check TTL; small contexts may not benefit, so avoid warming abandoned queries.

Permissions

Prerequisites

Permissions

Limitations

Model output may be incomplete or wrong; API and beta behavior can change, so verify against the pinned source and current service behavior.

Pinned upstream source

https://github.com/anthropics/anthropic-cookbook/blob/9c1e493ddd2b82df399d2a61b9c806c539e18be6/misc/speculative_prompt_caching.ipynb

Repository
anthropics/anthropic-cookbook
File path
misc/speculative_prompt_caching.ipynb
Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Take a coding Agent change from context to verification

Related resources