fix(agent): keep think tags in persisted agent session messages (#18222)

This commit is contained in:
euvre
2026-08-14 01:00:08 -07:00
committed by GitHub
parent 14c5a61350
commit e1330423ac
4 changed files with 135 additions and 4 deletions

View File

@@ -1395,6 +1395,14 @@ func (h *AgentHandler) AgentChatCompletions(c *gin.Context) {
if c, ok := evData["content"].(string); ok {
fullContent += c
}
// Mirror Python agent_api.py: the reasoning segment stays
// wrapped in <think> tags in the aggregated answer so the
// chat UI can render the "thought" section.
if st, _ := evData["start_to_think"].(bool); st {
fullContent += "<think>"
} else if et, _ := evData["end_to_think"].(bool); et {
fullContent += "</think>"
}
}
if ref, _ := evData["reference"].(map[string]any); ref != nil {
for k, v := range ref {