fix(chat): hide leaked provider citation markers - #626
Merged
Conversation
StackCairn
marked this pull request as draft
August 25, 2026 16:22
Contributor
|
PR governance checks passed. Awaiting human review. |
loto585
marked this pull request as ready for review
August 25, 2026 16:25
Stream sanitizer and stripProviderCitationMarkers now share one matcher so lookalike markup stays visible and unterminated markers are not flushed back on text_end. Co-authored-by: Cursor <cursoragent@cursor.com>
Member
|
Follow-up pushed:
Added coverage for lookalikes, char-by-char streaming vs strip agreement, and unterminated |
su-fen
approved these changes
Aug 25, 2026
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.
Linked issue
Closes #625
Summary
部分模型或中转服务会将 ChatGPT 私有联网搜索引用标记直接混入普通文本,例如:
这些标记属于 provider 内部协议元数据,不应显示在用户回答中。流式响应中该标记还可能被拆分到多个
text_delta,导致仅按单个 chunk 过滤无法清理。本 PR 在文本流和最终 assistant 消息两个阶段清理 provider citation markers,并增加跨 chunk 状态处理,避免这些标记出现在:
工具调用、图片等非文本内容不会被修改。
Change scope
agent-guicrates/agent-gui/src/lib/providers/runtime/messageUtils.tscrates/agent-gui/src/lib/providers/runtime/textOnlyRuntime.tscrates/agent-gui/src/lib/chat/runner/agentRunner.tscrates/agent-gui/src/lib/providers/llm.tscrates/agent-gui/test/providers/message-utils.test.mjsScreenshots / preview
这是一个聊天文本渲染行为修复,不涉及布局或视觉样式变化。
Runtime preview:
跨流式 chunk 的场景也会被处理:
Verification
Targeted provider and agent tests:
108 tests passedGUI build:
TypeScript 检查和 Vite 构建通过。
分支已同步最新
upstream/main,并确认无合并冲突。Pre-submit checklist
Closes #N.