Fix composite feedback functions to handle score parameter properly#150
Draft
Copilot wants to merge 2 commits into
Draft
Fix composite feedback functions to handle score parameter properly#150Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Reconsider how prevent_advanced_iteration (and similar) handle score parameter
Fix composite feedback functions to handle score parameter properly
Sep 2, 2025
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.
Problem
Composite feedback functions decorated with
@CompositeFeedbackFunction(likeprevent_advanced_iteration) were incorrectly passing composite-level parameters such asscoreto each constituent function. This caused score parameters to be multiplied by the number of triggered constituents instead of being applied once to the composite as a whole.Example of the issue:
Solution
Enhanced the
CompositeFeedbackFunctiondecorator to provide helper methods:extract_composite_parameters()- separates composite-level parameters (score,correct,muted,unscored,priority,label) from constituent-level parametersapply_composite_feedback()- creates a single composite feedback when any constituent is triggeredUpdated composite functions to use the new pattern:
prevent_advanced_iterationnow properly handles composite parametersensure_prints_exactlyupdated for consistencyMaintained full backward compatibility:
Key Changes
pedal/core/feedback.py: EnhancedCompositeFeedbackFunctiondecorator with parameter separation helperspedal/assertions/static.py: Updatedprevent_advanced_iterationandensure_prints_exactlyto use new mechanismtests/test_composite_feedback_score.py: Comprehensive test coverage for the new behaviorThe solution provides a clean, reusable mechanism that other composite feedback functions can adopt, addressing the core architectural issue where composite functions should be treated as single logical units rather than collections of independent functions.
Fixes #144.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.