feat(cache): add cache_ttl config knob for opt-in 1h prompt-cache TTL - #91
feat(cache): add cache_ttl config knob for opt-in 1h prompt-cache TTL#91Sam Schillace (ramparte) wants to merge 2 commits into
Conversation
…ilure at base 2e7232a) note that at base 2e7232a, tests in test_tool_repair.py fail with TypeError ('async for' requires __aiter__); fix is test-only, adds __aiter__/__anext__ emitting zero events to match the real SDK MessageStream contract; verified failing with all other changes reverted. Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
…che-ttl-2025-04-11) opt-in knob, OFF by default (flag-deletable: absent key => payloads byte-identical to pre-patch); exact value "1h" adds ttl to all 4 cache_control sites and appends the extended-cache-ttl-2025-04-11 beta header in the per-model header builder; any other value behaves as off; validated against live API (HQ9 E2: ephemeral_1h_input_tokens accounting confirmed); 19 unit tests in tests/test_cache_ttl.py, full suite 548 passed; verify via `bash verify.sh`. Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
|
This covers the config and wiring half of microsoft/amplifier#337 (linking for cross-reference; it can't auto-close from a comment, and the cost half below is still open). I had a branch for the same knob and retracted it because the TTL never reached Remaining gaps and follow-ups:
Separately: your first commit fixes the |
Feature: Optional 1-hour Prompt Cache TTL
Introduces an opt-in
cache_ttlconfiguration knob that enables 1-hour prompt-cache time-to-live (TTL) support via theextended-cache-ttl-2025-04-11beta. The knob is off by default — when absent, payloads are byte-identical to pre-patch versions (flag-deletable).Configuration:
cache_ttlextended-cache-ttl-2025-04-11appended to per-model header builder when enabledWhy This Is NOT a Duplicate of
cache_stable_region_ttl_1hThese are fundamentally different knobs serving different purposes:
cache_stable_region_ttl_1h(existing, #86):cache_ttl(this PR):{"type": "ephemeral", "ttl": "1h"}Different config keys, different implementation sites, different semantic meaning. The
cache_ttlknob operates at the payload level (per-block cache_control structure);cache_stable_region_ttl_1hoperates at the strategy level (which messages get cached).Testing
Unit tests: 19 new tests in
tests/test_cache_ttl.pyvalidating:Full suite: 548 tests passing, zero regressions
Live validation: Verified against live API (HQ9 E2 environment):
bash verify.shto validate: unit tests + full suite + grep assertions on cache_ttl guard sitesCommits
Proof of Production Usage
This branch has been running in production as a local source override on the author's machine (live since 2026-07-20), validating real-world stability and correctness.