Repository navigation
Conversation
get_prompt documents cache_ttl_seconds=0 as disabling caching, but the fetched prompt was still stored with a zero TTL. That replaced entries other callers had cached and let the next default-TTL call return the TTL-0 result instead of fetching. Skip the cache write when the TTL is 0, and keep evicting the key on a 404 so the cache never holds a prompt the server no longer has.
chrikrah
approved these changes
Nov 8, 2026
chrikrah
left a comment
There was a problem hiding this comment.
@Mo0nl19ht this matches the docstring ("Disables caching if set to 0"), and from my side it can be merged. The new test fails with only client.py reverted:
$ uv run --frozen pytest tests/unit/test_prompt.py -q # 49452e6, env from .env.template
27 passed in 2.36s
$ (same, client.py from 8e6c60d, head tests)
FAILED tests/unit/test_prompt.py::test_ttl_zero_fetch_does_not_write_to_cache
# not run: the e2e suite against a server
After a TTL-0-only call the cache is simply cold, so the existing fallback guidance for a first call already covers it. Nothing more needed in this PR.
6 of 11 tasks
This branch has not been deployed
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.
What does this PR do?
get_promptdocumentscache_ttl_seconds=0as disabling caching, but it only skips the cache read. The fetched prompt is still written to the cache with a zero TTL, so a TTL-0 call:_fetch_prompt_and_update_cachenow skips the cache write when the TTL is 0. Eviction on a 404 is unchanged, so the cache still drops prompts the server no longer has. TheLANGFUSE_PROMPT_CACHE_DEFAULT_TTL_SECONDSdefault path is not changed.Type of change
Verification
List the main commands you ran:
The new
tests/unit/test_prompt.py::test_ttl_zero_fetch_does_not_write_to_cachecovers an empty cache, the following default-TTL call, and an existing entry. It fails onmain(the TTL-0 fetch leaves aPromptCacheItemin the cache) and passes with this change. E2E and live-provider suites were not run; the change needs no server.Checklist
code_review.md..env.templateif needed. (Not needed; the docstring already describes this behavior.)

Confidence Score: 5/5
The PR appears safe to merge.Summary
Zero-TTL calls now fetch prompts without adding or replacing cached entries.
Reviews (5) · Last reviewed commit: "fix(prompts): skip cache write when cach..." · Reviewed by Greptile