Add per-fetch prompt cache control cache_ttl_seconds (0072)#172
Merged
Conversation
Advance the spec submodule pin v0.62.0 -> v0.63.1 to absorb accepted proposal 0072 (per-fetch cache_ttl_seconds prompt-cache control) at v0.63.0 plus the v0.63.1 patch (pipeline-utilities coverage fixtures 070/071). Updates __spec_version__, the pyproject spec_version, the smoke-test assertion, and regenerates the bundled AGENTS.md. conformance.toml records 0072 as implemented; the v0.63.1 fixtures add no proposal entry (coverage for the already-implemented 0069 / 0070).
PromptBackend.fetch, PromptManager.fetch, and PromptManager.get gain an optional cache_ttl_seconds read-side control: None preserves current behavior, 0 forces a fresh read past any client-side cache, and N > 0 bounds a served entry's staleness to N seconds; a negative value is rejected at the manager. It governs only which cached entry may be served, not whether or how results are cached. The bundled filesystem backend is cacheless and ignores it; the langfuse backend forwards it to the SDK's get_prompt cache. Every backend implementation (mocks + example backends) accepts the new param. Conformance: a caching prompt-backend harness primitive (source_read_count plus a controllable advance_clock) drives fixtures 033/034; unit tests cover the negative-value rejection and the langfuse forwarding.
Wire the v0.63.1 coverage fixtures into the conformance runners: 071 (fan-out degrade strict-reducer-raise) joins the failure-isolation set in the pipeline-utilities runner, and 070 (crash-injection after_node resume) joins the checkpoint runner alongside 067. python's behavior is already conformant (unit-tested in v0.14.0); this is harness selection.
Document the cache_ttl_seconds read-side control in the prompt-management concepts page, and add the 0.15.0 changelog entry plus advance the cycle's spec-pin bullet to v0.63.1 (proposal 0072 + the 070/071 patch).
There was a problem hiding this comment.
Pull request overview
Implements spec proposal 0072 by adding a per-fetch read-side prompt cache control (cache_ttl_seconds) across the prompt-management surface, and advances the pinned spec version to v0.63.1 (including wiring the v0.63.1 conformance coverage fixtures 070/071).
Changes:
- Add
cache_ttl_secondstoPromptBackend.fetch,PromptManager.fetch, andPromptManager.get, with manager-side validation for negative values. - Forward
cache_ttl_secondsthrough the Langfuse backend to the Langfuse SDK; accept-and-ignore it in the cacheless filesystem backend. - Extend the conformance prompt-management harness to support a caching primitive and backend end-state assertions; update spec/version documentation and changelog.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_prompts.py | Updates backend test doubles for new fetch signature; adds unit test for negative TTL rejection. |
| tests/unit/test_prompts_langfuse.py | Adds coverage asserting Langfuse backend forwards cache_ttl_seconds to the SDK. |
| tests/test_smoke.py | Updates spec version assertion to 0.63.1. |
| tests/conformance/test_prompt_management.py | Adds caching primitive + clock controls; wires direct-backend cache control and backend state assertions. |
| tests/conformance/test_pipeline_utilities.py | Wires fixture 071 into failure-isolation fixture set for v0.63.1 patch coverage. |
| tests/conformance/test_observability_langfuse.py | Updates mock prompt backend signature for protocol conformance. |
| tests/conformance/test_checkpoint.py | Wires fixture 070 into checkpoint fixture set for v0.63.1 patch coverage. |
| tests/conformance/harness/prompt_management.py | Extends fixture schema with caching primitive controls and expected backend state. |
| src/openarmature/prompts/manager.py | Adds cache_ttl_seconds to fetch/get and validates/rejects negative values. |
| src/openarmature/prompts/backends/langfuse.py | Forwards cache_ttl_seconds into Langfuse SDK get_prompt call path. |
| src/openarmature/prompts/backends/filesystem.py | Accepts (and ignores) cache_ttl_seconds to match updated protocol. |
| src/openarmature/prompts/backend.py | Updates PromptBackend protocol and documents cache control semantics. |
| src/openarmature/AGENTS.md | Updates bundled agent guide spec-version references to 0.63.1. |
| src/openarmature/init.py | Bumps __spec_version__ to 0.63.1. |
| pyproject.toml | Bumps [tool.openarmature].spec_version to 0.63.1. |
| examples/langfuse-observability/main.py | Updates example backend signature for protocol conformance. |
| examples/chat-with-multimodal/main.py | Updates example backend signature for protocol conformance. |
| docs/concepts/prompts.md | Documents cache_ttl_seconds behavior and examples. |
| conformance.toml | Records proposal 0072 as implemented and notes v0.63.1 fixture wiring. |
| CHANGELOG.md | Adds changelog entry for cache_ttl_seconds and updates spec pin note to v0.63.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR #172 review: _run_call's manager-target fetch/get dropped call.cache_ttl_seconds, so target: manager fixtures couldn't exercise the manager's threading (033/034 use direct-backend targets, so they were unaffected). Forward the control on both, matching the direct-backend path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements proposal 0072 (spec v0.63.0): a per-fetch
cache_ttl_secondsread-side cache control on the prompt-management surface, and folds in the v0.63.1 patch (pipeline-utilities coverage fixtures 070/071) in the same pin advance. Pins the spec submodule v0.62.0 -> v0.63.1.What changed
cache_ttl_secondscontrol.PromptBackend.fetch,PromptManager.fetch, andPromptManager.getgain an optionalcache_ttl_seconds:Nonepreserves current behavior,0forces a fresh read past any client-side cache, andN > 0bounds a served entry's staleness to N seconds. A negative value is rejected at the manager. It is a read-side control: it governs which cached entry may be served, not whether or how results are cached.get_promptcache (which takescache_ttl_secondsnatively, mappingNone/0/Ncleanly).source_read_countplus a controllableadvance_clock) drives fixtures 033/034. The v0.63.1 patch fixtures 070/071 (coverage for already-implemented 0069 / 0070 behavior, no new proposal) are wired into the pipeline-utilities and checkpoint runners.Design notes
The langfuse forwarding is slightly beyond the spec's strict minimum (which only requires threading the param plus cacheless-backend no-op), but the Langfuse SDK's
get_promptcaches and accepts the param natively, so forwarding makes OA's control actually govern langfuse prompt caching rather than silently ignoring it. python ships no production caching backend (the caching primitive is harness-only); the bundled backends are cacheless, matching §5's "cacheless backends treat it as a no-op."Testing
Notes
0.15.0changelog date is tentative pending the release tag.