Skip to content

feat(compress): configurable compression prompts (three-level, risk-gated) - #157

Merged
ranxianglei merged 3 commits into
masterfrom
2026-08-15_compress-prompts
Aug 15, 2026
Merged

ranxianglei merged 3 commits into
masterfrom
2026-08-15_compress-prompts

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Partially addresses #156 (the custom-prompts suggestion).

What

Adds compress.prompts + compress.acknowledgePromptsRisk to the existing three-level cascade (global → provider → model):

  • prompts overrides the kernel prompt text (compressPhilosophy, howToCompressRules, tier2DistillRules, tier3CondenseRules), merged sub-field-wise across levels — a model-level howToCompressRules does not discard a provider-level compressPhilosophy.
  • Resolved via the kernel's resolvePrompts (non-string fields silently dropped; a malformed partial never clobbers a good default).
  • Risk gate: the kernel rules are load-bearing (tuned in production); overrides are inert until acknowledgePromptsRisk: true at the winning level. Without it: one-time [compress] prompts override IGNORED warning + defaults.
  • Threaded consistently into the system prompt (all three protocols), the nudge text (renderNudgeText), and the compress loop in forward() — kernel contract: both layers must use the same Prompts.

Main use case: non-English / small-model prompt tuning (#156: 2B model spinning in the compress loop).

Stacking

Stacked on #153 (admin follow-up) — merge that first, then retarget this to master.

Verification

  • npm run typecheck clean; npm test 402/402 (6 new unit tests: three-level sub-field merge, risk-gate fallback, non-string drop, end-to-end route cascade).
  • npm run build clean (2.04 MB).
  • Docs: CONFIGURATION.md + CONFIGURATION.zh-CN.md field entries; CHANGELOG unreleased section. Web UI needs no change (settings page edits raw providers JSON).

…ated)

Adds `prompts` + `acknowledgePromptsRisk` to CompressSettings (#156):
- prompts override object (compressPhilosophy / howToCompressRules /
  tier2DistillRules / tier3CondenseRules), merged sub-field-wise across
  global > provider > model levels
- overrides are inert until acknowledgePromptsRisk: true at the winning
  level (kernel rules are load-bearing); one-time warn when ignored
- resolved via kernel resolvePrompts (non-string fields silently dropped)
- threaded consistently into system prompt, nudge text, and compress loop
- docs (EN/zh-CN) + 6 unit tests
@ranxianglei

Copy link
Copy Markdown
Owner Author

Cross-linking: this implements the custom-prompts suggestion from #156. The remaining #156 suggestions (repeat-failure short-circuit in the compress loop, repair hints in validation errors) are separate follow-ups.

@ranxianglei
ranxianglei changed the base branch from 2026-08-14_admin-followup to master August 15, 2026 01:14
…pts override

Regression review findings on #157:
- the three builder templates had a lone trailing space where master had an
  empty line — the default-path system prompt differed by one byte from
  pre-upgrade output, breaking the prefix-cache anchor. Verified fixed:
  default-path output of all three builders is now BYTE-IDENTICAL to
  origin/master (direct string comparison against a snapshot import).
- adds tests/e2e-compress-prompts.test.ts: real startServer proxy + mock
  upstream capturing the wire body. Proves (1) provider+model sub-field
  merged overrides reach the upstream system message, (2) overrides are
  inert without acknowledgePromptsRisk (defaults on the wire + warn log),
  (3) no-config path keeps the kernel default prompt.
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