feat(context): make payload-summary char cap configurable per profile#4
Open
whoabuddy wants to merge 1 commit into
Open
feat(context): make payload-summary char cap configurable per profile#4whoabuddy wants to merge 1 commit into
whoabuddy wants to merge 1 commit into
Conversation
The hardcoded 4000-char cap inside `summarizeJson` truncated task payloads regardless of the profile's `context_policy.max_prompt_chars`, which meant evidence-heavy review tasks (curated PR diffs, structured audits) lost most of their payload before reaching the model — even on profiles whose prompt budget had room to spare. Add an optional `max_payload_chars` field to `context_policy` and thread it through `buildPromptText` → `summarizeJson`. Default behavior is unchanged: profiles that don't set the field keep the 4000-char cap (now exported as `DEFAULT_MAX_PAYLOAD_CHARS`). Tests cover three cases: default (no override, 4000 cap applies), higher override (12000 lets a 8000-char payload through), and lower override (1000 cap truncates a 2000-char payload).
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
Make the per-task payload-summary character cap configurable via
profile.context_policy.max_payload_chars. Default behavior is unchanged — profiles that don't set the field continue to use the existing 4000-char cap (now exported asDEFAULT_MAX_PAYLOAD_CHARS).Why
The hardcoded
MAX_PAYLOAD_CHARS = 4000insidesummarizeJson(src/context.ts:10) truncated task payloads regardless ofcontext_policy.max_prompt_chars. Profiles whose prompt budget has plenty of room (16K–32K) still lost most of their evidence payload because the payload section itself was capped at 4K before assembly.Concrete case: a fleet-council review profile shipping a curated PR diff in
payload.curated_diff_excerptonly saw the first ~3KB of the diff after JSON-stringification, despitemax_prompt_chars: 18000and an assembled prompt totaling ~7KB. The bottleneck was the payload cap, not the prompt cap.What changes
src/context.ts: renameMAX_PAYLOAD_CHARStoDEFAULT_MAX_PAYLOAD_CHARSand export it;summarizeJsonnow accepts an optionalmaxCharsparameter;buildPromptTextpassesprofile.context_policy.max_payload_charsthrough.src/types.ts: add optionalmax_payload_chars?: numbertoProfile.context_policywith a doc comment explaining when to set it.src/runtime.test.ts: three new tests covering default behavior (unchanged), higher override (lets a previously-truncated payload through), and lower override (truncates aggressively when desired).Backward compat
Fully backward compatible. The field is optional. Profiles without it use
DEFAULT_MAX_PAYLOAD_CHARS = 4000— identical to the current behavior. No migration required.Test plan
bun test— 118 pass / 0 fail (3 new tests, no regressions)bun test -t "payload"— 3 new tests passCaller migration (none required)
Profiles that need bigger payload budgets opt in:
{ "context_policy": { "include_recent_task_memory": false, "max_prompt_chars": 32000, "max_payload_chars": 20000 } }Profiles that don't set the field keep the current 4000-char cap.
🤖 Generated with Claude Code