Skip to content

Conversation

@krrishdholakia
Copy link
Contributor

Title

Implement Langfuse Data Masking via Dynamic Parameters

Relevant issues

N/A

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

This PR introduces support for passing a masking function to Langfuse, enabling users to redact sensitive information from inputs and outputs before they are sent to the Langfuse server.

Key changes include:

  • langfuse_masking_function Parameter: Added a new langfuse_masking_function parameter to StandardCallbackDynamicParams and LangfuseLoggingConfig.
  • Langfuse Client Integration: The LangFuseLogger now accepts this function and passes it directly to the Langfuse SDK's mask parameter during client initialization.
  • Dynamic Logger Caching: The LangFuseHandler has been updated to correctly propagate the masking function through the dynamic logging parameter flow. A new caching mechanism uses id(function) for cache key generation, as functions are not JSON serializable, ensuring that different masking functions result in distinct cached loggers.
  • Dedicated Tests: Comprehensive unit tests have been added to verify the correct detection, propagation, and caching behavior of the masking function.

Slack Thread

Open in Cursor Open in Web

Co-authored-by: krrishdholakia <krrishdholakia@gmail.com>
@cursor
Copy link

cursor bot commented Dec 10, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Dec 10, 2025 4:34pm
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

4 participants