Skip to content

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

Merged
kxzk merged 2 commits intomainfrom
feature/align-ruby-prompt-cache-default-key-with-jspython-production
Mar 6, 2026
Merged

fix(prompt-cache): align default key with production semantics#63
kxzk merged 2 commits intomainfrom
feature/align-ruby-prompt-cache-default-key-with-jspython-production

Conversation

@kxzk
Copy link
Collaborator

@kxzk kxzk commented Feb 23, 2026

Summary

  • Default prompt cache key now appends :production when neither version nor label is specified, aligning with JS/Python SDK semantics.
  • Corrected docs/PROMPTS.md which incorrectly described the default fetch behavior as "latest" — it actually resolves to the production-labeled prompt.

Test plan

  • bundle exec rspec — 1198 examples, 0 failures, 98.06% coverage
  • bundle exec rubocop — no offenses

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.

@kxzk kxzk self-assigned this Mar 6, 2026
@kxzk kxzk force-pushed the feature/align-ruby-prompt-cache-default-key-with-jspython-production branch from 7a4cbb1 to 8891c3b Compare March 6, 2026 10:14
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Simplify nil check to `unless version || label` and correct
PROMPTS.md which incorrectly described the default as "latest".
@kxzk kxzk merged commit ecb17bf into main Mar 6, 2026
10 checks passed
@kxzk kxzk deleted the feature/align-ruby-prompt-cache-default-key-with-jspython-production branch March 6, 2026 10:20
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.

2 participants