Skip to content

feat(context): make payload-summary char cap configurable per profile#4

Open
whoabuddy wants to merge 1 commit into
mainfrom
feat/configurable-max-payload-chars
Open

feat(context): make payload-summary char cap configurable per profile#4
whoabuddy wants to merge 1 commit into
mainfrom
feat/configurable-max-payload-chars

Conversation

@whoabuddy
Copy link
Copy Markdown
Contributor

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 as DEFAULT_MAX_PAYLOAD_CHARS).

Why

The hardcoded MAX_PAYLOAD_CHARS = 4000 inside summarizeJson (src/context.ts:10) truncated task payloads regardless of context_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_excerpt only saw the first ~3KB of the diff after JSON-stringification, despite max_prompt_chars: 18000 and an assembled prompt totaling ~7KB. The bottleneck was the payload cap, not the prompt cap.

What changes

  • src/context.ts: rename MAX_PAYLOAD_CHARS to DEFAULT_MAX_PAYLOAD_CHARS and export it; summarizeJson now accepts an optional maxChars parameter; buildPromptText passes profile.context_policy.max_payload_chars through.
  • src/types.ts: add optional max_payload_chars?: number to Profile.context_policy with 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 pass

Caller 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

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant