Skip to content

feat(compress): opt-in nudge-low-effort — clamp thinking/effort on first compression-nudge turn (#617) - #619

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-05_nudge-low-effort
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-05_nudge-low-effort

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Port of billion-context#1640 / billion-context PR#1780 into pi-acp, addressing #617: lower the model's thinking/reasoning effort specifically on the compression turn.

Behavior — new opt-in config compress.nudgeLowEffort

Boolean, default false, resolved through the same three-level cascade as every other compress.* field (global -> provider -> model). When enabled:

  • On the first request of a compression-nudge episode — the one carrying a freshly-injected nudge — the already-present thinking/effort field in the outbound provider body is clamped toward the wire floor for that single turn only, then restored on the next request.
  • Targets exactly the summary-writing turn where thinking models burn a large reasoning budget.
  • Clamp-only: rank-based lowering (none < minimal < low < medium < high < xhigh < max) down to low; never injects an absent field and never raises a value (a no-reasoning none stays none).
  • Prompt-cache-safe: the effort parameter sits outside the message prefix; only that one request's payload changes, so prefix-cache hit rate is untouched.
  • Dialects covered: anthropic thinking.budget_tokens -> 1024, openai/responses reasoning_effort / reasoning.effort -> low, gemini generationConfig.thinkingConfig.thinkingBudget -> 128 (-1 dynamic left alone).

Regression / behavior notes

  • Default off = zero regression: with the flag unset the hook returns pi's untouched payload reference (byte-identical), identical to prior behavior.
  • The before_provider_request handler previously early-returned when stripImages was disabled; it now always runs so the two opt-in wire levers compose. Observable behavior for strip-images users is unchanged; for everyone else the added per-request work is inert bookkeeping (two Map lookups + a flag check).
  • No acp-kernel change, no cross-repo dependency, package version untouched.

Tests

28 new cases in tests/nudge-low-effort.test.ts mirroring PR#1780: per-wire clamp + floor, below-floor never raised, absent not injected, unknown/none never raised (rank rule), google -1 untouched, idempotent, malformed/null/array safe, null-protocol no-op, classifier-independent (clamps a plain user turn too), decision truth-table, config three-level merge + default-off. Existing strip-images and nudge-reinject suites remain green. Typecheck + build clean. Full suite runs in CI.

Closes #617.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到。这是 [PR] 镜像 issue,对应 PR #619(分支 2026-10-05_nudge-low-effort)。按流程不重做工作:正在拉取分支核对代码、查 CI 状态、跑定向验证,完成后给出结构化七问 review 结论。

…rst compression-nudge turn

Port of ranxianglei/billion-context PR#1780 (settled in #1640) into pi-acp.

New opt-in config compress.nudgeLowEffort (default off): on the FIRST request of a compression-nudge episode, clamps the already-present thinking/effort field toward the wire floor for that one turn only, restoring on the next request. Targets the summary-writing turn where thinking models burn a large reasoning budget. Clamp-only (rank-based: never injects or raises a value), prompt-cache-safe (effort sits outside the message prefix). Dialects: anthropic thinking.budget_tokens->1024, openai/responses reasoning_effort/reasoning.effort->low, gemini thinkingBudget->128.

Wired through before_provider_request (composed with strip-images; also fixes the prior early-return that skipped the hook entirely when stripImages was disabled) plus a fresh-nudge signal armed at the context-transform nudge-push site. No acp-kernel change, no cross-repo dependency. 28 new tests.

Closes #617. Refs ranxianglei/billion-context#1640, PR#1780.
@ranxianglei
ranxianglei force-pushed the 2026-10-05_nudge-low-effort branch from c49da1e to 7d5151d Compare October 5, 2026 16:13
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-10-05_nudge-low-effort (7d5151d)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-619

Each push to this PR publishes a new version under the pr-619 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr619.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #619 review 完成(rebased head 7d5151d,CI 全绿)— 可合并,待 owner 拍板

查重

全仓检索 nudgeLowEffort / reasoning_effort / budget_tokens / thinkingBudget(含已关闭 issue/PR):仅 #617(原始需求)与本 PR,无重复。

我做了什么(已验证)

PR 分支基于旧 master(fork 点落后 ~25 个提交),GitHub 报 mergeable_state: dirty——src/runtime.ts 与 master 上 #515(persist-nudge-records)、#605(khat-calibration)的新增代码冲突。处理:

  1. 本地 rebase 到当前 master tip f9dc713,3 处冲突 hunk 全部是「双方各自新增相邻代码」→ 按意图并集解决(clearNudgeTracking 清理、函数定义区、return 方法列表三处均保留双方);
  2. 核对自动合并区:armNudgeInjected(src/index.ts:869)与 feat(nudge): persist nudge injections as display-only session entries (closes #326) #515 的 nudge 持久化块(src/index.ts:889)同处 !alreadyShown 分支,语义一致;
  3. 本地定向验证:typecheck ✅、build ✅、5 个定向套件(nudge-low-effort/strip-images/nudge-reinject/nudge-record/config)112 tests 全绿 ✅(全量回归按纪律交给 CI);
  4. force-with-lease 推送更新分支 → 新 head 7d5151d,diff stat 与原 PR 完全一致(7 files +371/-20,无夹带)。

CI(新 head):9 个 check run 全 success(test ubuntu/windows × node 22/24、e2e ×2、build-artifact、docker、pr-validation)。当前 blocked = 仅缺人工 review。

既有行为回归审查(逐项)

触碰路径的既有行为 结论
默认关时出站 payload 保持:hook 返回 pi 原 payload 引用,字节级不变(测试钉住)
stripImages 行为 保持:仅去掉 early-return,两个 opt-in lever 组合;strip 用户观感不变(suite 绿)
nudge 注入/重注入节奏(#598/#601 死区、re-inject floor) 保持:未动注入决策,只在注入后记一个 pending flag
nudge 持久化记录(#515) 保持:冲突并集解决,markNudgeRecorded 路径完整,nudge-record suite 绿
khat 校准 / host-floor(#605/#601) 保持:仅 return 列表并集,逻辑零改动
.acp.json sidecar / 日志回放重建 不涉及:新状态纯内存(Map),不落盘
ref-tag / token 计量 / 前缀缓存 不涉及:effort 参数在消息前缀之外,只改单请求 payload

已知局限(非阻塞,留档供 owner 决定)

连续两个回合各出现一次全新 nudge episode(压缩后立即又越过 growthFloor)时,第二 episode 的首回合会漏掉一次 clamp(prev flag 要等一个无注入回合才复位)。下回合即自愈;且机制无法区分「模型没压」与「压完又涨」,要修需引入 compress-outcome 追踪(更多状态)。opt-in 实验特性,代价至多多烧一轮高 effort——建议接受现状,不单独立项(同机制族,归本 PR 线程)。

结构化七问

  1. 是什么问题:功能请求([Feature] Is it possible to pass the reasoning_effort option during compression? | [Feature]是否可以在压缩时增加传递reasoning_effort选项 #617)——harness 默认的高 reasoning 设置(xhigh)被透传到 ACP 压缩摘要那一轮,白白烧掉大量 reasoning 预算;需要按轮覆盖的手段。
  2. 什么原因导致的:非缺陷。Pi 侧 provider 请求体只有一个全局 effort 来源,插件此前没有「针对特定回合降档」的 wire 级抓手(stripImages 是同位置先例)。
  3. 怎么修复的:新增 opt-in compress.nudgeLowEffort(默认 false,三级级联)。nudge episode 首个 provider 请求把已存在的 effort 字段钳向 wire 下限(anthropic budget_tokens→1024;openai/responses effort→low,rank 表 none<minimal<low<medium<high<xhigh<max;gemini thinkingBudget→128,-1 动态不动),下一请求自动恢复。只降不升、绝不注入缺失字段、乱值不动;host 侧实现,零 kernel 依赖。
  4. 是否有回归问题:无。默认关 = 字节级不变;唯一有意变更已在 PR 披露(before_provider_request 不再因 stripImages 关而 early-return,对非 strip 用户是无害记账:两次 Map lookup + 一个 flag)。既有行为清单见上表,逐项保持。
  5. 是否破坏缓存:否。effort 参数位于消息前缀之外,仅单个请求自身 payload 变化,prefix-cache hit rate 不受影响;默认关时连 clone 都不发生。
  6. 是否改了设计方向:否。沿用 stripImages 建立的 host-side wire lever 模式,同一 hook 组合两个 opt-in 开关;无架构转向,package version 未动。
  7. 是否引入了新的配置:是——compress.nudgeLowEffort,boolean,默认 false,global/provider/model 三级级联,CONFIGURATION 中英双文档已标 🟡 EXPERIMENTAL。无需迁移(opt-in、默认关)。

测试质量:28 个新 case 断言有牙(逐 wire clamp+floor、低于 floor 不抬、缺失不注入、unknown/none 不抬、google -1 不动、幂等、输入不被原地改、malformed 安全、null-protocol no-op、classifier 无关、decision 真值表+整周期、config 三级合并+默认关),bug 回归时可抓得住。

判定:代码、测试、文档、CI 均就绪,可合并。 按 §7.4 auto-merge gate,本 PR 属 feat: + 新增配置面 → 必须人工合并,我不会代合。请 owner 批准后自行 merge:#619

This branch has not been deployed

No deployments
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.

[Feature] Is it possible to pass the reasoning_effort option during compression? | [Feature]是否可以在压缩时增加传递reasoning_effort选项

1 participant