Skip to content

[BUG] batchingGuidance 默认开启且无每会话上限:我的 22 个 ops-ptc 日常会话累计 349 条 user 注入,单会话最高 80 条 #1027

Closed

Description

@qikairo7

环境

  • dsh-ops:0.5.5,插件管理器(pnpm)安装,profile=desktop
  • DSH:Desktop 0.2.2-rc.5,profile=desktop
  • 操作系统:Windows 11 x64
  • 预设:ops-ptc(selectedDefault),batchingGuidance 未显式关闭(默认 true)

现象

我在自己的 Windows 11 机器上使用 dsh-ops 0.5.5,默认走 ops-ptc。每次根 run_code 程序触发 plan / bypass / shape 检查时,插件都会把一条
[Plugin context from "batching-guidance"; not a user instruction or authorization.]
以 user 角色消息追加进会话历史。同一用户回合内每类检查最多一次,但每个新回合都会重新触发,没有每会话上限,所以长会话会一直累积。

我统计了自己 2026-11-17~11-19 的 695 个本地会话日志,按目录 id 关联 projcache,排除 webhook、worker、orchestrator 和子代理会话,只保留有真实用户消息的根会话,共 78 个:

  • standard:52 个会话,仅 1 个触发,共 8 条
  • ops-ptc:22 个会话,19 个触发(86%),共 349 条;均值 15.9 条/会话,最高 80 条/会话
  • 典型分布:3 个会话 0 条、2 条×2、3 条×3、5 条×2、6 条×2、8 条×1、17 条×2、19/20/31/32/42/48/80 各 1 个

最小复现

  1. 新建 ops-ptc 会话,保持 batchingGuidance 默认(true)。

  2. 连续 3 个用户回合,每回合让 agent 执行一个首行不含 // plan: 的 run_code 程序,例如:

    // 无 plan 行,并执行一次 shell 文件操作
    await tools.ops_bash({ command: "ls", description: "list files" })
    return { ok: true }

  3. 每个回合结束后查看历史,会出现 [Plugin context from "batching-guidance"...],角色为 user;增加用户回合数,条数继续增长。

期望行为

  • 首轮教学只注入一次;后续纠偏不要作为 user 角色消息进入历史,或只进入 batchingTelemetry;
  • 增加每会话上限(例如 maxNoticesPerSession,默认 10–20 条),超过后只记录,不注入;
  • 默认值改为 false,或在插件页暴露开关,避免默认安装就产生大量 user 消息。

实际读数

见上方「现象」。数据来自我本机 2026-11-17~11-19 的 ops-ptc 默认配置;需要的话我可以补统计脚本和脱敏后的分布表。

是否在隔离环境复现过

只在真实 profile 中复现;未在隔离 DSH_HOME 做长跑(需要的话可以补)。

其他

Activity

  1. Thatgfsj commented on Nov 20, 2026

    @Thatgfsj
    Collaborator

    新版本已经进行修复,过两天发

  2. Thatgfsj commented on Nov 20, 2026

    @Thatgfsj
    Collaborator

    报告的核心症状已被 #1008(现经 #1033 合入 main)消除:一次性教学不再写入 logged history,而是随首个被接受的根 run_code 结果走同一步 additionalContexts(contributor batching-guidance:lesson),且每 agent 条目只投递一次;逐违规提醒同样走 additionalContexts,不进入用户历史。因此「349 条 user 注入 / 单会话最高 80 条」的累积通道不复存在,也不再需要用会话上限去抑制历史增长。证据:src/publication/ptc.ts、test/prompt-ephemeral-teaching.test.mjs、docs/CHANGELOG.md 的 #929 条目。若在 0.5.5+ 上仍观察到 user 角色注入,请另开新单并附会话日志。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions