Repository navigation
fix(chat): 模型开始运行即清提示气泡,截断后丢弃失效摘要 - #14
Merged
Merged
Conversation
… on truncate Two context/hint fixes: - The retry/interrupt/error sticker on the last assistant row survived until the first stream delta's defensive clear, because clearInlineError() targets the last assistant row and the new placeholder becomes that row. runAgentLoop now clears the stale sticker BEFORE appending the new placeholder, so the hint bubble disappears the moment the model starts running rather than after the first token lands. - deleteFromMessage / retryFromMessage rebuilt agentHistory from the truncated DB tail but left llmDigestLines intact. That digest summarizes rows trimAgentHistory evicted — after a truncation some of those rows are gone and the window moved, so their summaries were stale memory of deleted content that effectiveAgentHistory() kept injecting on every turn. Both paths now drop the digest (the user-initiated _compactSummary is a separate store and is preserved).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
做了什么
两个上下文/提示修复:
重试/中断/错误气泡在模型开始运行后消失:旧代码里
clearInlineError()清的是"最后一条 assistant 消息",而runAgentLoop启动时会先插入新的占位气泡成为最后一条——导致旧消息上的错误贴纸要等到第一个流式增量到达才被防御性清掉,中间有可见窗口。现在在插入新占位气泡之前先清旧贴纸,让气泡在模型开始运行的瞬间就消失。长按"从此处删除"/重试后不再残留被删内容的记忆:
deleteFromMessage/retryFromMessage截断后重建了agentHistory,但没清llmDigestLines——那是被自动 trim 出窗口的消息摘要,effectiveAgentHistory()每次发送都会注入它。删除后其中部分消息已不存在、窗口边界也变了,旧摘要就成了"删了还在上下文里"的失效记忆。现在两条路径都丢弃该摘要(用户主动压缩的_compactSummary是独立存储,保留)。测试
本机无 JDK,编译与单测交由 CI。
关于
begin 0, end 376, length 375切片错误我用截图(消息正文残留上次崩溃的
StringIndexOutOfBoundsException, 1047 bytes),证明是"崩溃→持久化→再崩溃"的循环)穷举了流式 markdown 渲染、块拆分、inline 解析、文本选择、offload stub 等约 40 处substring/take/subSequence,全部有越界防护,未找到能产生该异常的无防护切片点。该异常的确切位置需要一条完整堆栈跟踪才能定位——本 PR 不含此项修复,避免无依据乱改。