Skip to content

Commit cd7ae3e

Browse files
committed
refactor(web): always enable static-prefix prompt caching
Remove the SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_PREFIX_ENABLED lever so the static checkpoint is always emitted, and switch the remaining cache env vars to JSDoc comments so their descriptions render on IDE hover.
1 parent 8610781 commit cd7ae3e

3 files changed

Lines changed: 7 additions & 19 deletions

File tree

packages/shared/src/env.server.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,13 @@ const options = {
311311

312312
SOURCEBOT_CHAT_MAX_STEP_COUNT: numberSchema.default(100),
313313
SOURCEBOT_CHAT_PROMPT_CACHING_ENABLED: booleanSchema.default('true'),
314-
// Phased-rollout lever for the static checkpoint. Set to 'false' to fall
315-
// back to the single moving tail marker. Only takes effect when prompt
316-
// caching is enabled.
317-
SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_PREFIX_ENABLED: booleanSchema.default('true'),
318-
// TTL for the static block. The moving tail marker always uses the 5m default.
314+
/** TTL for the static block. The moving tail marker always uses the 5m default. */
319315
SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_TTL: z.enum(['5m', '1h']).default('5m'),
320-
// Observability: when enabled, logs a warning on unexpected prompt-cache
321-
// breaks (static-prefix signature changes, or zero cache reads on a
322-
// continuation step). Does not affect request behavior.
316+
/**
317+
* Observability: when enabled, logs a warning on unexpected prompt-cache
318+
* breaks (static-prefix signature changes, or zero cache reads on a
319+
* continuation step). Does not affect request behavior.
320+
*/
323321
SOURCEBOT_CHAT_PROMPT_CACHE_BREAK_DETECTION_ENABLED: booleanSchema.default('false'),
324322
SOURCEBOT_MCP_TOOL_CALL_TIMEOUT_MS: numberSchema.int().positive().max(maxTimerDelayMs).default(60000),
325323

packages/web/src/ee/features/chat/agent.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ vi.mock('@sourcebot/shared', () => ({
2727
SOURCEBOT_CHAT_MAX_STEP_COUNT: 8,
2828
SOURCEBOT_CHAT_MODEL_TEMPERATURE: 0,
2929
SOURCEBOT_TELEMETRY_PII_COLLECTION_ENABLED: 'false',
30-
// Enable the static front checkpoint so marker placement is exercised;
31-
// whether markers are actually emitted is then controlled by the
32-
// PromptCacheStrategy passed into each call.
33-
SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_PREFIX_ENABLED: 'true',
3430
SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_TTL: '5m',
3531
SOURCEBOT_CHAT_PROMPT_CACHE_BREAK_DETECTION_ENABLED: 'false',
3632
},

packages/web/src/ee/features/chat/agent.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,6 @@ const createAgentStream = async ({
391391
const mcpRegistry = buildMcpToolRegistry(mcpToolSetsObj.tools);
392392
const hasMcpTools = mcpRegistry.length > 0;
393393

394-
// Phased-rollout lever for the static checkpoint. When disabled, only the
395-
// moving tail marker is emitted and behavior collapses to the prior
396-
// single-breakpoint scheme.
397-
const useStaticPrefix = env.SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_PREFIX_ENABLED === 'true';
398394
const staticTtl = env.SOURCEBOT_CHAT_PROMPT_CACHE_STATIC_TTL;
399395

400396
const toolRequestActivation = tool({
@@ -455,9 +451,7 @@ const createAgentStream = async ({
455451
// Caveat: when MCP tools are lazily activated mid-run via prepareStep, the
456452
// tools section grows and invalidates both breakpoints for that step; the
457453
// cache re-warms on subsequent steps once the active tool set is stable.
458-
const staticMarker = useStaticPrefix
459-
? promptCacheStrategy.cacheControl({ ttl: staticTtl })
460-
: undefined;
454+
const staticMarker = promptCacheStrategy.cacheControl({ ttl: staticTtl });
461455
const systemMessages: SystemModelMessage[] = [
462456
{ role: 'system', content: staticPrompt, providerOptions: staticMarker },
463457
];

0 commit comments

Comments
 (0)