refactor: prioritize raw model output in chat history archiving to ensure accurate capture of tool call and thinking markup

This commit is contained in:
CJACK
2026-05-03 15:44:17 +08:00
parent 837dc74ffc
commit 5e55cf36d8
6 changed files with 142 additions and 16 deletions

View File

@@ -195,6 +195,24 @@ func (s *chatStreamRuntime) markContextCancelled() {
s.finalFinishReason = string(streamengine.StopReasonContextCancelled)
}
func (s *chatStreamRuntime) historyText() string {
if s == nil {
return ""
}
return historyTextForArchive(s.accumulator.RawText.String(), s.finalText)
}
func (s *chatStreamRuntime) historyThinking() string {
if s == nil {
return ""
}
return historyThinkingForArchive(
s.accumulator.RawThinking.String(),
s.accumulator.ToolDetectionThinking.String(),
s.finalThinking,
)
}
func (s *chatStreamRuntime) resetStreamToolCallState() {
s.streamToolCallIDs = map[int]string{}
s.streamToolNames = map[int]string{}