Skip to content

Comments

fix(prompt-cache): align default key with production semantics#63

Open
kxzk wants to merge 1 commit intomainfrom
feature/align-ruby-prompt-cache-default-key-with-jspython-production
Open

fix(prompt-cache): align default key with production semantics#63
kxzk wants to merge 1 commit intomainfrom
feature/align-ruby-prompt-cache-default-key-with-jspython-production

Conversation

@kxzk
Copy link
Collaborator

@kxzk kxzk commented Feb 23, 2026

Supersedes #57 after branch rename to conventional format.

TL;DR

Why

Checklist

  • Has label
  • Has linked issue
  • Tests added for new behavior
  • Docs updated (if user-facing)

Closes #

Summary

  • Updated Langfuse::PromptCache.build_key to default no-version/no-label keys to name:production.
  • Kept existing explicit version/label key behavior unchanged and updated cache key expectations in prompt cache, Rails cache adapter, and API client specs.
  • Added an unreleased changelog entry documenting JS/Python parity for default prompt cache key semantics.
  • Tests/validation: bundle exec rspec (1154 examples, 0 failures, 98.04% coverage), bundle exec rubocop (no offenses), and Langfuse CLI API contract check via npx langfuse-cli api prompts get --help confirming default prompt retrieval semantics.

Architecture (Core Change)

Mermaid not applicable (cache-key default behavior and test expectation updates only).

Copilot AI review requested due to automatic review settings February 23, 2026 20:17
@kxzk kxzk added the bug Something isn't working label Feb 23, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 23, 2026

Greptile Summary

Updated prompt cache key generation to default unlabeled/unversioned fetches to name:production format, aligning with Langfuse JS/Python SDK semantics.

Key changes:

  • Modified PromptCache.build_key to append :production when both version and label are nil
  • Correctly maintains existing behavior for explicit version/label parameters
  • Updated all test expectations across cache, API client, and Rails adapter specs
  • Added CHANGELOG entry documenting the breaking change

Validation:

  • All 1154 tests passing with 98.04% coverage
  • No Rubocop offenses
  • Langfuse CLI contract verified per PR description

Confidence Score: 5/5

  • Safe to merge - straightforward cache key format change with comprehensive test coverage
  • Single-line logic change with clear intent, all tests updated consistently, validates against Langfuse API contract, and maintains backward compatibility for explicit version/label usage
  • No files require special attention

Important Files Changed

Filename Overview
lib/langfuse/prompt_cache.rb Added :production suffix to cache keys when no version/label specified, aligning with API default behavior
spec/langfuse/prompt_cache_spec.rb Updated test expectations for build_key to expect :production suffix on unlabeled prompts
spec/langfuse/api_client_spec.rb Updated cache key expectations throughout API client integration tests to use :production suffix

Last reviewed commit: 7a4cbb1

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the default prompt cache key generation behavior to align with JavaScript and Python SDK semantics. When fetching prompts without specifying a version or label, the cache key now defaults to name:production instead of just name, ensuring consistency across Langfuse SDKs.

Changes:

  • Modified PromptCache.build_key to append :production suffix when both version and label are nil
  • Updated all test expectations across prompt cache, Rails cache adapter, and API client specs to reflect the new default behavior
  • Added unreleased changelog entry documenting the change and cross-SDK alignment

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/langfuse/prompt_cache.rb Core implementation: adds :production suffix to cache keys when version and label are unspecified
spec/langfuse/prompt_cache_spec.rb Updated test expectations for name-only cache key generation
spec/langfuse/rails_cache_adapter_spec.rb Updated test expectations for Rails cache adapter key building
spec/langfuse/api_client_spec.rb Updated mock expectations to use :production suffix in cache key assertions
CHANGELOG.md Documented the semantic change in the unreleased section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant