Skip to content

feat: smart compression prompts — tiered guidance and compression priority#9

Merged
ranxianglei merged 4 commits into
masterfrom
2026-06-13_smart-compression-prompts
Jun 13, 2026
Merged

feat: smart compression prompts — tiered guidance and compression priority#9
ranxianglei merged 4 commits into
masterfrom
2026-06-13_smart-compression-prompts

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Root cause fix: Model was compressing at 10%+ context usage because the context usage text unconditionally said "use the compress tool proactively" regardless of actual usage level
  • System prompt rewrite: Added tiered compression philosophy (ample/moderate/high), compression priority guidance (what to compress first vs carefully), and recovery breadcrumb generation
  • Context usage injection: Three-tier guidance based on actual usage percentage instead of one-size-fits-all "compress now"

Changes

System prompt (lib/prompts/system.ts)

  • Removed aggressive "Manage context continuously" / "Evaluate REGULARLY"
  • Added CONTEXT PRESSURE LEVELS:
    • Ample (<40%): Do NOT compress unless obvious waste
    • Moderate (40-55%): Compress completed sections proactively
    • High (>55%): Compress aggressively but selectively
  • Added WHAT TO COMPRESS FIRST (bash output, dead-ends, redundant results)
  • Added WHAT TO COMPRESS CAREFULLY (secrets, file paths, function signatures, errors)
  • Added BEFORE COMPRESSING: verify important content is persisted externally
  • Added AFTER COMPRESSING: generate recovery breadcrumbs

Context usage text (inject.ts + utils.ts)

  • Old: "You ARE the ACP agent — use the compress tool proactively" (always)
  • New: Three-tier guidance:
    • <40%: "Context is ample — focus on your task. Only compress obvious waste."
    • 40-55%: "Context is moderate — compress completed sections."
    • >55%: "Context is high — compress aggressively but selectively."

Test plan

  • typecheck clean
  • build success
  • 386/386 tests pass
  • E2E: verify model stops compressing at low context usage

…ompression priority

- Rewrite system prompt: conservative compression when context is ample,
  aggressive only when high. Added compression priority guidance (what to
  compress first vs carefully) and recovery breadcrumb generation.
- Replace unconditional 'use compress proactively' with tiered guidance:
  ample (<40%): focus on task, minimal compression
  moderate (40-55%): compress completed sections
  high (>55%): compress aggressively but selectively
- Remove hardcoded 40%/55% from system prompt, use qualitative descriptions
- Extract shared buildContextUsageGuidance() that reads minContextLimit/maxContextLimit from config
- Both inject.ts and utils.ts now use config-driven thresholds for tiering
- ACP threshold shown in usage text now reflects actual maxContextLimit config value
@ranxianglei ranxianglei merged commit ed6114f into master Jun 13, 2026
3 checks passed
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