mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
fix(channel): strip agent tags from content parts in outbound messages
StripAgentTags was only applied to the merged content string but not to individual ContentParts. On channels that don't support RichText (e.g. Telegram), buildChannelMessage joins part texts directly, causing raw <attachments>/<reactions>/<speech> blocks to appear in the final message.
This commit is contained in:
@@ -30,6 +30,7 @@ func ExtractAssistantOutputs(messages []conversation.ModelMessage) []conversatio
|
||||
continue
|
||||
}
|
||||
content = agent.StripAgentTags(content)
|
||||
parts = stripAgentTagsFromParts(parts)
|
||||
outputs = append(outputs, conversation.AssistantOutput{Content: content, Parts: parts})
|
||||
}
|
||||
return outputs
|
||||
@@ -87,6 +88,22 @@ func visibleContentText(parts []conversation.ContentPart) string {
|
||||
return strings.TrimSpace(strings.Join(texts, "\n"))
|
||||
}
|
||||
|
||||
func stripAgentTagsFromParts(parts []conversation.ContentPart) []conversation.ContentPart {
|
||||
if len(parts) == 0 {
|
||||
return nil
|
||||
}
|
||||
result := make([]conversation.ContentPart, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
if strings.TrimSpace(p.Text) != "" {
|
||||
p.Text = agent.StripAgentTags(p.Text)
|
||||
}
|
||||
if p.HasValue() {
|
||||
result = append(result, p)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func visibleContentPartText(part conversation.ContentPart) string {
|
||||
if strings.TrimSpace(part.Text) != "" {
|
||||
return part.Text
|
||||
|
||||
Reference in New Issue
Block a user