FIX: Ensure conversation scoring only adds once to memory#1989
Open
jbolor21 wants to merge 2 commits into
Open
FIX: Ensure conversation scoring only adds once to memory#1989jbolor21 wants to merge 2 commits into
jbolor21 wants to merge 2 commits into
Conversation
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.
Description
Conversation Scorer adds to memory twice!
Previously, the
._score_asynccalled the wrapped scorer's publicscore_asyncfunction, which persists scores to memory. This meant the outer Scorer.score_async (that invoked _score_async) then persisted them a second time, producing two identical ScoreEntry rows per call. The previous workaround regenerated each score's id via uuid.uuid4() after the inner call to dodge the collision, but this still meant the scores were still being written twice (with different IDs).Fix:
Call the wrapped scorer's protected _score_async instead. This skips the inner persist (and the inner validator/role-filter/blocked-content substitution, which is safe here because the synthetic conversation message we build is pure text with response_error="none"). The outer Scorer.score_async now persists the returned scores exactly once, keyed to the original message_piece_id. The ID-regeneration workaround is removed.
Tests and Documentation