feat: optionally enforce playbook token budget - #44
Open
Frankie-Xu wants to merge 1 commit into
Open
Frankie-Xu wants to merge 1 commit into
Frankie-Xu wants to merge 1 commit into
Conversation
Frankie-Xu
marked this pull request as ready for review
September 18, 2026 16:59
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.
Addresses the playbook-bloat concern in #26 with an opt-in budget guardrail. It does not implement DELETE/MERGE/UPDATE, replace the prompt loader in #38, change PR #43, or claim that a budget alone fixes validation oscillation.
This adds
enforce_playbook_token_budget(defaultfalse) to ACE, ACEBatch and the three task entry points. When enabled, the existingcount_tokens/cl100k_basecounter measures the resulting playbook only. The curation boundary rejects an over-budget candidate before publication, returns the original playbook unchanged, does not consumenext_global_id, and records structured diagnostics: status, base/candidate/budget token counts and reason. Bullet content is never silently truncated. Empty operations and exact-boundary candidates are covered.Ordinary Curator curation attaches the decision to
call_info; the ACEBatch reducer uses the same pure helper before assigning its playbook and ID and exposes the decision in per-sample tracking. The default path retains existing tuple/config behavior.Tests cover exact-boundary acceptance, over-budget rejection, empty operations, default compatibility and opt-in config extraction, Curator structured rejection, reducer output/state preservation, and no ID consumption. Validation: 7 unittest tests passed, compileall and diff-check passed, and the same suite passed from a clean git archive. No LLM, API key, network request, benchmark, or upstream main push was used.