Prompts: Fetch Policy
Prompt fetching takes a policy, so you choose whether a prompt is read from cache or fetched fresh on every call.
Fetch Policies
Each policy is optimized for a different deployment scenario.
-
MATERIALIZED_FIRST (default)
-
ALWAYS_FETCH
-
CACHE_TTL
-
MATERIALIZED_ONLY
What You Can Do Now
-
Configure different fetch policies per environment (development, staging, production) while keeping the same prompt IDs in code.
-
Run fully offline in sensitive environments using
MATERIALIZED_ONLY, or opt into live updates withALWAYS_FETCHorCACHE_TTL. -
Keep prompts consistent and auditable across deployments by pairing fetch policies with the prompts lockfile and materialized directory.
# Always fetch from API, use materialized as fallback
prompt = langwatch.prompt.get_prompt(
"customer-support-bot",
fetch_policy=FetchPolicy.ALWAYS_FETCH
)
# Fetch every 5 minutes, use materialized between fetches
prompt = langwatch.prompt.get_prompt(
"customer-support-bot",
fetch_policy=FetchPolicy.CACHE_TTL
cache_ttl_minutes=5
)
# Never fetch, use materialized only (air-gapped mode)
prompt = langwatch.prompt.get_prompt(
"customer-support-bot",
fetch_policy=FetchPolicy.MATERIALIZED_ONLY
)
# Default behavior: use materialized if available, otherwise fetch
prompt = langwatch.prompt.get_prompt(
"customer-support-bot",
fetch_policy=FetchPolicy.MATERIALIZED_FIRST # default
)
Rollout
-
Start: 2025-12-16
-
Completion: 2025-12-16
-
Availability: Python SDK, Typescript SDK
Notes
Author & Review
-
Author: @Andrew Joia
-
Reviewed by: [@Reviewer]
-
Created: 2025-12-16