Add generic RSA (Recursive Self-Aggregation) algorithm framework#124
Open
shashankk42 wants to merge 11 commits into
Open
Add generic RSA (Recursive Self-Aggregation) algorithm framework#124shashankk42 wants to merge 11 commits into
shashankk42 wants to merge 11 commits into
Conversation
83e7a55 to
cdc9fa2
Compare
9b73603 to
ffbe801
Compare
bvanessen
reviewed
May 12, 2026
tbennun
requested changes
May 12, 2026
| _DEFAULT_AGGREGATION_TEMPLATE = _PROMPTS_DIR / "default_aggregation_template.txt" | ||
|
|
||
|
|
||
| # Generic default output schema |
Contributor
There was a problem hiding this comment.
This code and all the classes seem quite excessive. Why do we need a class for RSAPrompts? If RSA extends a Task we should add those fields there?
| ) | ||
|
|
||
|
|
||
| class RSACallbacks: |
Contributor
There was a problem hiding this comment.
unnecessary to put in a separate class
| return task | ||
|
|
||
|
|
||
| class RSATaskFactories(Generic[T]): |
Contributor
There was a problem hiding this comment.
Why make a generic RSA task factory? What is the need for the factory design pattern? I thought that there should just be an RSATask that extends Task
| k = config.k | ||
|
|
||
| # Helper function to run a single proposal | ||
| async def run_single_proposal(proposal_index: int, proposal_runner: Any): |
Contributor
There was a problem hiding this comment.
Long nested functions... Hard to understand the flow.
| await callbacks.logger_info(f"Generated {len(proposals)} valid proposals") | ||
|
|
||
| # Helper function to run a single aggregation | ||
| async def run_single_aggregation( |
Create charge/algorithms/ with RSAConfig, RSACallbacks, RSATaskFactories to make RSA reusable for any task type.
Add task-agnostic default prompts that users can swap out for domain-specific needs.
Document how to use default prompts and swap them for domain-specific needs.
Add GenericRSAOutput schema, default_format_candidates, and default task factories so RSA works immediately without customization.
Allows domain-specific prompts to be passed to aggregation tasks, enabling clean separation between generic RSA and domain customization.
- system_prompt: Domain expert definition (constant across proposal and aggregation) - proposal_prompt: Task instructions for generating proposals - aggregation_prompt: Task instructions for evaluating/aggregating This provides cleaner separation: expertise (system) vs task (user prompt).
- Add minimal working example using ChARGe only - Document 3-part prompt structure (system, proposal, aggregation) - Remove stale 2-part prompt references - Clear progression from basic to advanced usage - Remove flask-copilot dependencies from examples
- Enforce N, K, T >= 2 (T=1 would skip aggregation) - Enforce K <= N at construction time in RSAConfig.__post_init__ - Remove redundant K validation in run_rsa_loop - Improve error messages with actionable guidance - Add logging when K is adjusted due to proposal failures
79c870e to
4435b50
Compare
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.
Summary
Add generic Recursive Self-Aggregation (RSA) algorithm with 3-part prompt structure.
Changes
charge/algorithms/rsa.pywith N-K-T RSA implementationsystem_prompt: Domain expert definition (same for proposals and aggregations)proposal_prompt: Task instructions for generating solutionsaggregation_prompt: Task instructions for evaluating/synthesizing solutionsRSAConfig,RSAPrompts,RSACallbacks,RSATaskFactoriesrun_rsa_loop()with parallel proposal generation and recursive aggregationAPI
Testing
Related PRs