Repository navigation
fix(langfuse): key end-user attribution by profile so senders can't cross profiles - #448
Open
fredheathcote007 wants to merge 1 commit into
Conversation
…ross profiles NousResearch#293 scoped trace state and shutdown to the active profile, but the sender maps (_SENDER_BY_TURN, _USER_BY_CHILD_SESSION) stayed keyed by bare turn and child-session ids. Under a multiplexed gateway two profiles can reuse those ids, so: - profile B's trace exported profile A's sender as its userId, even when B never opted in to end_user_attribution; - two opted-in profiles with the same turn id swapped senders; - a subagent session id reused in B inherited A's user, and B's subagent_stop cleared A's inherited user. Key both maps with the same per-profile namespace as the trace state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
#293 scoped trace state and shutdown to the active profile. The two end-user attribution maps were not included:
_SENDER_BY_TURNand_USER_BY_CHILD_SESSIONare still keyed by bare turn and child-session ids. Under a multiplexed gateway, two profiles can reuse those ids. Their senders then cross over:user-afor turnsame-turn. Profile B hasend_user_attributionoff, but its turn with the same id opens withuserId = user-a.subagent_stopclears the user that A's child inherited.The
end_user_attributionopt-in is per profile, so this is a privacy issue: one profile's end-user id reaches a Langfuse project that never opted in.Fix
Both maps are now keyed with the same per-profile namespace that #293 uses for trace state (
_profile_attribution_key→profile:<home>:<id>). The namespace stays in process; nothing new is exported.Tests
Added to
test_langfuse_multiprofile_lifecycle.py, using its existing two-profile fixture:test_opted_out_profile_never_exports_another_profiles_sender'user-a' == '')test_same_turn_id_keeps_each_profiles_own_sender'user-b' == 'user-a')test_subagent_user_is_inherited_only_within_its_profile'user-a' == '')test_concurrent_profiles_with_the_same_turn_ids_keep_their_senders(64 racing iterations)test_sender_stash_is_boundednow expects the namespaced keys.The full langfuse suite passes (182 tests) and
hermes plugins validatepasses. Both were run on Linux with Python 3.14 against current hermes-agent main, using the install steps from this repo'stests.yml. I haven't run them on macOS or Windows locally; CI covers those.🤖 Generated with Claude Code