Skip to content

feat: principle-driven compression — minimal intervention, block sizes, file decompress#47

Open
ranxianglei wants to merge 1 commit into
masterfrom
ranxianglei/2026-07-01_principle-driven-prompts
Open

feat: principle-driven compression — minimal intervention, block sizes, file decompress#47
ranxianglei wants to merge 1 commit into
masterfrom
ranxianglei/2026-07-01_principle-driven-prompts

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

Complete redesign of ACP compression prompts from rule-driven (72 lines of rules) to principle-driven (~20 lines of principles). Plus new features for better context awareness.

Prompt Redesign

  • system.ts: 72 lines → 20 lines. Removed all thresholds, levels, priority lists. Two principles only: over-compression harms quality, under-compression causes overflow.
  • BE FRUGAL section: 5 examples of obvious waste to compress (command output, sub-agent results, training logs, duplicate reads, failed explorations).
  • utils.ts: buildContextUsageGuidance returns just context number — no guidance text.
  • inject.ts: Per-message shows only Context: X%. Every 10 percentage points (from 15%): Tips show tool names. Below 15%: no compression prompts. At 65%: stronger overflow warning.
  • nudge.ts: Removed consolidation suggestion. Block list now shows token counts: b50 (76t), b51 (88t), ...

Tool Improvements

  • compress: Single 3000-char limit (removed soft/hard dual-tier). New summaryMaxChars optional parameter for override.
  • decompress: New toFile optional parameter — writes content to file without inflating context. Block stays compressed.
  • search_context: Already has good description (searches compressed + visible).
  • Fixed: Empty backtick tags in system.ts (<dcp-message-id> and <dcp-system-reminder>).
  • Fixed: Plan B auto-detect consumed blocks (no manual (bN) placeholders needed).
  • Fixed: Directive nudge range calculation (uses anchorMessageId, visible range filter, no backwards ranges).

Config

  • minNudgeContextPercent: 15 (don't nudge below 15%)
  • perMessageNudgeGrowthPercent: 10 (percentage points, not relative %)
  • nudgeFrequency: 6

Files Changed (11 files, +158/-118)

  • lib/prompts/system.ts — principle-driven rewrite + BE FRUGAL + tag fix
  • lib/messages/inject/utils.ts — simplified to context number only
  • lib/messages/inject/inject.ts — 10pp interval gating + min threshold
  • lib/prompts/extensions/nudge.ts — removed consolidation, added block token counts
  • lib/compress/range.ts — summaryMaxChars parameter
  • lib/compress/message.ts — summaryMaxChars parameter
  • lib/compress/decompress.ts — toFile parameter
  • lib/compress/search.ts — (already good description)
  • lib/config.ts — minNudgeContextPercent
  • tests/nudge-text.test.ts — updated assertions
  • devlog/2026-07-01_principle-driven-prompts/ — REQ.md + WORKLOG.md

@ranxianglei ranxianglei force-pushed the ranxianglei/2026-07-01_principle-driven-prompts branch 5 times, most recently from 2287df2 to 77098fe Compare July 2, 2026 00:40
@ranxianglei ranxianglei changed the title feat: principle-driven compression prompts — minimal intervention feat: principle-driven compression — minimal intervention, block sizes, file decompress Jul 2, 2026
@ranxianglei ranxianglei force-pushed the ranxianglei/2026-07-01_principle-driven-prompts branch 16 times, most recently from ddad4e8 to 41c37b0 Compare July 3, 2026 14:21
…ery 10% tips

- system.ts: 72 lines → 15 lines (principles only, no thresholds/levels/lists)
- utils.ts: buildContextUsageGuidance returns just context number (no guidance text)
- inject.ts: gating uses 10pp intervals from 15%, Tips show tools not commands
- nudge.ts: removed consolidation suggestion
- config.ts: added minNudgeContextPercent (default 15)
- tests: updated assertions for simplified output
@ranxianglei ranxianglei force-pushed the ranxianglei/2026-07-01_principle-driven-prompts branch from 41c37b0 to 0f41b88 Compare July 3, 2026 15:11
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