fix(trace): include instruction content in system_instruction span key - #1974
Merged
looplj merged 1 commit intoJul 7, 2026
Merged
Conversation
Contributor
spanToKey was missing a case for "system_instruction", causing all system instruction spans to share the same key regardless of content. This led to different system prompts being incorrectly deduplicated when building the segment tree.
ChancenJ
force-pushed
the
fix/trace-system-instruction-dedup
branch
from
July 7, 2026 07:27
fbacf9c to
3a9f267
Compare
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.
问题描述
在追踪 OpenCode、Claude Code 等 agent 会话时,发现追踪页面只显示一个系统提示词,即使多个请求都有不同的系统提示词(如生成标题的系统提示词和主 agent 的系统提示词)。
根因分析
spanToKey函数为每个 span 生成唯一 key 用于去重比较。但该函数缺少对system_instruction类型的处理,导致所有系统提示词 span 都返回相同的空字符串 key,无法区分不同内容,被错误去重。修复方案
在
spanToKey中添加system_instruction的处理,将指令内容纳入 key 的生成。这样:
影响范围
spanToKey函数,不影响其他去重逻辑