You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Retract a message so it leaves the model's context / 撤回消息并真正移出模型上下文
#1492
A Retract action on a user message in a Bot chat, which removes the message
from the model's context instead of only hiding it in the UI.
Two cases, one interaction:
Last user message: retract it together with everything after it (assistant
steps, tool calls and results). The original text goes back to the input box
so it can be edited and resent.
An earlier user message: the same button, the same confirmation, the same
"Message retracted" placeholder and the same text refill, but the chat
continues in a forked session. The original session is left untouched, and
the UI says so clearly.
Why
A Bot session is long-lived, so a wrong or outdated instruction stays in its
context. Today it cannot be edited out, and compaction only summarizes.
Retracting would let a conversation be corrected without starting over.
Concretely: a message can be sent too quickly, with the wrong wording or the
wrong intent, and the mistake is only noticed afterwards. The same happens
when a reply is stopped halfway and it turns out that the message which
triggered it should never have been sent. In both cases the message cannot be
taken back, so it stays in the context and keeps influencing every later turn —
the context is polluted for the rest of the session. Retraction is exactly the
missing piece for that case.
How I would implement it
No DSH changes needed — this uses the documented surface API, the same mechanism src/host/browser/mount.js already uses for oversized tool results.
Append a developer/message with empty content, carrying surfaceOp: { op: 'replace', startSeq, endSeq } and a sourceEventSeqs list
that densely covers every shadowed surface node, then ctx.sessions.flush().
An empty message derives to null, so the carrier leaves no trace of its own.
Whole-turn granularity only: no deleting a single node from the middle, which
would split tool calls from their results.
The earlier-message case uses the existing session fork API at the event just
before that message; nothing is rewritten in the original session.
Client side: a Retract button next to the existing copy button on a user
message, one shared confirmation dialog, and a placeholder rendered by DS Bot
itself. A new api/bot endpoint does the work; the send path is unchanged.
Retraction is refused while a reply is running.
Tests with the mock model, plus a design note in docs/plans/ if you consider
this a large feature.
Known limits (would be stated in the change)
The original text stays in the on-disk session log; retraction removes it from
the model's context, not from disk.
The placeholder appears in DS Bot's own chat rendering, not in DSH's native
transcript.
Each replacement bumps contentGeneration, so the next turn re-opens a request
series and the prompt cache prefix is rebuilt.
Scope: single-Bot chats in the DS Bot client. Group chats, IM delivery,
steering messages and the mobile app are out of scope for this change.
Two questions
Do you want this feature? If yes, I will write the implementation plan in
the resulting issue before writing any code, as CONTRIBUTING.md asks.
How should a non-collaborator contribute it? CONTRIBUTING.md says that for
now only collaborators can open pull requests. Would you add me as a
collaborator so I can open the PR myself, or would you rather receive the
change another way — a full patch attached to the issue, or a branch on my
fork that you pull from? I will follow whichever route you prefer.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
English
The idea
A Retract action on a user message in a Bot chat, which removes the message
from the model's context instead of only hiding it in the UI.
Two cases, one interaction:
steps, tool calls and results). The original text goes back to the input box
so it can be edited and resent.
"Message retracted" placeholder and the same text refill, but the chat
continues in a forked session. The original session is left untouched, and
the UI says so clearly.
Why
A Bot session is long-lived, so a wrong or outdated instruction stays in its
context. Today it cannot be edited out, and compaction only summarizes.
Retracting would let a conversation be corrected without starting over.
Concretely: a message can be sent too quickly, with the wrong wording or the
wrong intent, and the mistake is only noticed afterwards. The same happens
when a reply is stopped halfway and it turns out that the message which
triggered it should never have been sent. In both cases the message cannot be
taken back, so it stays in the context and keeps influencing every later turn —
the context is polluted for the rest of the session. Retraction is exactly the
missing piece for that case.
How I would implement it
No DSH changes needed — this uses the documented surface API, the same mechanism
src/host/browser/mount.jsalready uses for oversized tool results.developer/messagewith emptycontent, carryingsurfaceOp: { op: 'replace', startSeq, endSeq }and asourceEventSeqslistthat densely covers every shadowed surface node, then
ctx.sessions.flush().An empty message derives to
null, so the carrier leaves no trace of its own.would split tool calls from their results.
before that message; nothing is rewritten in the original session.
message, one shared confirmation dialog, and a placeholder rendered by DS Bot
itself. A new
api/botendpoint does the work; the send path is unchanged.docs/plans/if you considerthis a large feature.
Known limits (would be stated in the change)
the model's context, not from disk.
transcript.
contentGeneration, so the next turn re-opens a requestseries and the prompt cache prefix is rebuilt.
steering messages and the mobile app are out of scope for this change.
Two questions
the resulting issue before writing any code, as CONTRIBUTING.md asks.
now only collaborators can open pull requests. Would you add me as a
collaborator so I can open the PR myself, or would you rather receive the
change another way — a full patch attached to the issue, or a branch on my
fork that you pull from? I will follow whichever route you prefer.
中文
想法
在 Bot 会话的用户消息上提供「撤回」,把它真正从模型上下文移除,
而不是只在界面上隐藏。
两种情况,同一套交互:
一起撤回,原文回填到输入框,方便改完重发。
同样的原文回填,但续聊发生在 fork 出的新会话里;原会话保持不动,
界面上明确提示这一点。
为什么
Bot 会话是长命的,一条发错或过时的指令会一直留在上下文里。现在无法把它
编辑掉,压缩也只是做摘要。能撤回的话,就不用推翻重开一段对话。
具体说:消息可能发得太快,用词不对或意思不对,发出去之后才察觉;也可能是
一次回复进行到一半按了停止,才发现自己触发它的那条消息本就不该发。这两种
情况现在都没法把消息撤掉,它就留在上下文里,持续影响后面的每一轮——整个会话
的上下文从此被污染。撤回要补的正是这个缺口。
实现思路
不需要改 DSH,全部走公开的 surface API——
src/host/browser/mount.js里对超长工具结果已经这么做了。
content的developer/message,带surfaceOp: { op:'replace', startSeq, endSeq }和密集覆盖所有被遮蔽surface 节点的
sourceEventSeqs,再ctx.sessions.flush()。空消息派生结果为
null,载体自身不留痕。新增一个
api/bot端点,发送路径不动。docs/plans/设计说明。已知边界(改动里会写明)
contentGeneration,下一轮重建 prompt cache 前缀。移动端不在本次范围内。
两个问题
issue 里写清实现方案,再动代码。
方便加我为协作者、由我自己开 PR 吗?还是更希望以别的形式接收改动——
完整补丁附在 issue 里,或者我 fork 上的分支供你们拉取?哪种都可以,
按你们方便的来。
All reactions