Skip to content

fix(core): honor zero prompt cache TTL - #1531

Draft
Solaris-star wants to merge 1 commit into
VoltAgent:mainfrom
Solaris-star:fix/prompt-cache-zero-ttl
Draft

Solaris-star wants to merge 1 commit into
VoltAgent:mainfrom
Solaris-star:fix/prompt-cache-zero-ttl

Conversation

@Solaris-star

@Solaris-star Solaris-star commented Nov 12, 2026 •

Copy link
Copy Markdown

PR Checklist

  • Conventional commit message
  • Related issue linked
  • Regression tests added
  • Patch changeset added

Current behavior

A per-prompt ttl: 0 is treated as absent when reading an existing cache entry. Even an entry originally cached with zero TTL can be reused when the next lookup occurs in the same millisecond.

New behavior

Honor zero explicitly and expire it immediately. Positive and default TTL behavior, including the existing positive-TTL expiry boundary, is unchanged.

Part of #1493, only its prompt-cache TTL correctness item. This does not close the broader issue or change MCP authentication, sandboxing, logging, or cache-key selection. #1522 excludes this item; #1521 concerns cache keys.

Validation

  • Seven new tests exercise the real prompt manager and API client with only the fetch boundary replaced by synthetic JSON responses and a fake clock. Unchanged base: 4 failed, 3 passed. Fixed: 7 passed.
  • New and existing prompt manager/API-client selection: 57 passed.
  • Full core with an explicit process-local OTEL_TRACES_SAMPLER=always_on: 1,407 passed, 2 skipped, 1 todo across 111 files; type tests passed. The clean base under the same condition passed 1,400 tests, with the same 2 skips and 1 todo.
  • The inherited environment used parentbased_traceidratio with ratio 0.01. Its first core runs failed the same 16 named observability tests on both base and fixed code. Those results are retained; no global or production sampling setting was changed.
  • Core TypeScript checking, strict checking of the new tests, internal/logger/core builds, repository Biome, changeset formatting, and core publint --strict passed. Biome reported 5 existing complexity warnings; publint reported 2 suggestions.
  • Independent AI review repeated the 4-fail/3-pass to 7-pass result and checked two additional boundaries: exact positive TTL expiration and normal caching after a one-call zero override.

Environment: Linux, Node 24.22.1, pnpm 8.10.5, frozen repository lockfile. Dependency setup completed with optional native-build warnings; unrelated browser and CUDA downloads were skipped using their supported settings. No dependency or lockfile changes are included.

No live VoltOps/model calls, full-monorepo build/test, or Node 20/22 matrix was performed. The seven new cases are included in the larger totals above, not additive. Draft CI is configured upstream to skip its jobs, so local validation is not remote-CI success.

Notes for reviewers

Prepared, tested, and independently reviewed with OpenAI Codex assistance. No prior human or maintainer approval is claimed. The patch is limited to TTL handling, seven regressions, and its changeset.


Summary by cubic

Honors a prompt cache TTL of zero so cached prompts expire immediately. Previously ttl: 0 was treated as absent, letting an entry cached with zero TTL be reused; now it expires even when the next lookup happens in the same millisecond. Positive and default TTL behavior are unchanged. This addresses only the prompt-cache TTL correctness item in #1493; MCP authentication, sandboxing, logging, and cache-key selection (#1521, #1522) are untouched.

Tests

  • Adds seven regression tests covering global and per-prompt zero TTL, same-millisecond lookups, and TTL override precedence.

Written for commit 0649c99. Summary will update on new commits.

View guided diff

@coderabbitai

coderabbitai Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0649c99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@voltagent/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant