Skip to content

fix(ptc): file batching guidance under its producer source - #1041

Merged
Nicholas023 merged 1 commit into
T-Auto:mainfrom
Nicholas023:fix-guidance-source-kind
Nov 21, 2026
Merged

Nicholas023 merged 1 commit into
T-Auto:mainfrom
Nicholas023:fix-guidance-source-kind

Conversation

@Nicholas023

@Nicholas023 Nicholas023 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1040

What was wrong

agent/pre-step delivered the batching lesson and every bypass/plan/shape notice with
source: { kind: 'user' }. Chat draws a bubble exactly when that kind is user, so a session showed
dozens of English "user" messages the human never typed — indistinguishable from real input, and from
the user's authorization.

That source was deliberate (the text must read as the instruction that governs the task, not a tool
result the model can skip), so the fix has to keep the model-facing weight and change only how the
client files the message.

The change

  • src/publication/ptc.ts: deliver the batch as
    source: { kind: 'dsh-ops:batching-guidance', contributor, revision, turn, step } instead of
    { kind: 'user' }. role stays user and no plugin envelope is added, so the model still reads
    it as the governing instruction; the client files an unknown kind under its producer.
  • src/ptc/batching-guidance.ts: export BATCHING_GUIDANCE_SOURCE_KIND and declare the producer kind
    on the host's merge-extensible MessageSourceMap (the host documents unknown user-message kinds as
    falling through to their producer).
  • Tests: prompt-user-teaching, resident-switch and ptc-cost-accounts assert the new kind and the
    unchanged role: 'user' and envelope-free body.
  • Docs (zh + en) and CHANGELOG describe the plugin source instead of source kind user.

Deliberately not done: adding back the [Plugin context … not a user instruction] envelope
suggested in #1040. That prefix is exactly what the current design removes on purpose; adding it back
would lower the model's weight on the text the lesson exists to deliver. The delivery also still enters
logged history — agent-loop appends every non-runtime-context pre-step message as user/message —
so this change fixes the presentation and the source attribution, not the fact that the injection is
logged.

Validation

Host: win32-x64, Node v24.21.0.

$ node scripts/verify-gate.mjs --skip-install
ok   versions
ok   cargo version
ok   build the plugin
ok   native worker unit tests
ok   build and stage the native worker
ok   stage complete frozen Niubash payload
ok   Acquire explicit legacy MSYS fixture
ok   Legacy Windows IPC payloads
ok   manifest contract
ok   full suite verification
ok   staged runtime closure
ok   pack the release artifact
ok   unpack the release artifact
ok   packed runtime closure
275 suites passed; skipped: linux-attributes, linux-shell, tui-host, tui-native (allowed: file-metadata, linux-attributes, linux-shell, tui-host, tui-native)
manifest: 92/59 checks
win32-x64: gate green

Target suites inside that run:

dsh-ops prompt-user-teaching: all 3 checks passed
dsh-ops ptc-cost-accounts: all 2 checks passed
dsh-ops resident-switch: all 28 checks passed

Real-host check (isolated DSH_HOME, web UI, OPS (PTC) preset, one real task): the only user bubble
is the task the human typed; the guidance renders as a collapsed 上下文注入 · dsh-ops:batching-guidance
row beside runtime-context and skill-catalog, and the session log carries two
source.kind: 'dsh-ops:batching-guidance' messages with role: 'user' and no envelope. The model still
acted on them (it earned a shape notice).

  • 本 PR 有一次 pull_request 事件触发的 CI required run,且已把该 run 的 URL 贴到下方代码块
  • node scripts/verify-gate.mjs --skip-install 的实际输出(见上)
  • 撤掉本次实现后,相关检查会变红(行为级红绿,而非只看代码结构)
CI required run: https://github.com/T-Auto/dsh-ops/actions/runs/44888649687
conclusion: success
jobs: workflow-lint, rust-lint, source-size, node-floor,
      validate (win32-x64 | linux-x64 | darwin-x64 | darwin-arm64),
      tools-trial, CI required — all success

Revert check: setting kind back to 'user' and rebuilding fails prompt-user-teaching with
2 of 3 check(s) failed (the guidance filter and the source assertion), then passes again once
restored — the assertions are behavioural, not structural.

The pre-step batch delivered the lesson and every corrective notice with
`source: { kind: 'user' }`, so Chat drew them as user bubbles and a session
looked like the user had typed dozens of English instructions nobody wrote
(T-Auto#1040).

Deliver them under the plugin's own source kind instead. Each message keeps
`role: 'user'` and carries no plugin envelope, so the model still reads it as
the instruction that governs the task; the client files an unknown kind under
its producer and draws no user bubble.

Pinned by the prompt-user-teaching, resident-switch and ptc-cost-accounts
suites; the bilingual docs and CHANGELOG describe the new source.
@Nicholas023
Nicholas023 merged commit bfdfdf6 into T-Auto:main Nov 21, 2026
18 of 20 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.

[Bug] 0.5.6 把插件 batching-guidance 提示反复渲染成用户气泡,污染单个会话的聊天记录

1 participant