Problem
The JS SDK's loadPrompt and loadParameters flows unconditionally construct a DiskCache (js/src/logger.ts, BraintrustState constructor) whenever canUseDiskCache() returns true. The only documented knobs are BRAINTRUST_PROMPT_CACHE_DIR / BRAINTRUST_PARAMETERS_CACHE_DIR (path) and *_CACHE_MEMORY_MAX / *_CACHE_DISK_MAX (size) — none of which disable the cache.
We run our own in-memory cache on top of loadPrompt (refresh-on-interval, cold-start fallbacks) and the SDK's disk cache is redundant. It's also actively harmful when the container's HOME points at a path the runtime user can't mkdir into — we hit this on AWS Fargate with HOME=/tmp, producing repeated warnings in production logs:
Failed to write to disk cache Error: ENOENT: no such file or directory, mkdir '/tmp/.braintrust'
at async PromptCacheService.refreshOne (...)
at async PromptCacheService.refreshAll (...)
Request
One of:
- A public option on
loadPrompt({ noDiskCache: true }) / a disableDiskCache arg on initLogger
- A
BRAINTRUST_DISABLE_DISK_CACHE=1 env var
- Or document that setting
BRAINTRUST_PROMPT_CACHE_DIR="" (empty string) disables it, and make the code honor that
Current workaround
Redirect the cache dir to a known-writable path at image build time via BRAINTRUST_PROMPT_CACHE_DIR / BRAINTRUST_PARAMETERS_CACHE_DIR. Works, but persists a redundant on-disk cache for no benefit.
Version
braintrust@3.8.0 (JS SDK)
Problem
The JS SDK's
loadPromptandloadParametersflows unconditionally construct aDiskCache(js/src/logger.ts,BraintrustStateconstructor) whenevercanUseDiskCache()returns true. The only documented knobs areBRAINTRUST_PROMPT_CACHE_DIR/BRAINTRUST_PARAMETERS_CACHE_DIR(path) and*_CACHE_MEMORY_MAX/*_CACHE_DISK_MAX(size) — none of which disable the cache.We run our own in-memory cache on top of
loadPrompt(refresh-on-interval, cold-start fallbacks) and the SDK's disk cache is redundant. It's also actively harmful when the container'sHOMEpoints at a path the runtime user can'tmkdirinto — we hit this on AWS Fargate withHOME=/tmp, producing repeated warnings in production logs:Request
One of:
loadPrompt({ noDiskCache: true })/ adisableDiskCachearg oninitLoggerBRAINTRUST_DISABLE_DISK_CACHE=1env varBRAINTRUST_PROMPT_CACHE_DIR=""(empty string) disables it, and make the code honor thatCurrent workaround
Redirect the cache dir to a known-writable path at image build time via
BRAINTRUST_PROMPT_CACHE_DIR/BRAINTRUST_PARAMETERS_CACHE_DIR. Works, but persists a redundant on-disk cache for no benefit.Version
braintrust@3.8.0(JS SDK)