fix(outbound): keep single-run answers whole and show formulas

The DingTalk binding can point at the quick-answer agent, which publishes the
whole answer as one answer run plus tool_call/tool_result steps. The narration
boundary was rejected for that shape (start=0), so the text-only heuristic ran
and dropped the answer lead-in together with its image.

- answer_observation: a single answer run means there is no narration to cut.
- outboundtext: rewrite LaTeX formulas into plain Unicode text, because
  DingTalk cards render no math typesetting (r = sqrt(X^2 + Y^2) -> r = √(X² + Y²)).
- dingtalk handler: normalize formulas on both the partial and final card paths.
This commit is contained in:
姚章浩
2026-09-18 16:21:37 +08:00
parent dfce8cb9f6
commit 5ccaeb3b96
8 changed files with 439 additions and 1 deletions
+3
View File
@@ -11,6 +11,7 @@ import (
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/core"
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/directory"
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/outboundtext"
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/reasoningmode"
"gitea.zheromiku.top/Weknora/dobotai-platform/internal/weknora"
)
@@ -675,6 +676,7 @@ func (h *Handler) finalizeCardOrMarkdown(ctx context.Context, webhookURL string,
}
func (h *Handler) rewriteOutboundContent(ctx context.Context, content string) string {
content = outboundtext.NormalizeMath(content)
options := tableNormalizeOptions{groupWideTables: h.groupTablesFinal}
if h.outboundRewriter == nil {
return normalizeMarkdownTables(sanitizeDisplayAnswer(content), options)
@@ -692,6 +694,7 @@ func (h *Handler) rewriteOutboundContent(ctx context.Context, content string) st
}
func (h *Handler) sanitizeOutboundPartial(ctx context.Context, content string) string {
content = outboundtext.NormalizeMath(content)
sanitizer, ok := h.outboundRewriter.(OutboundPartialSanitizer)
if ok {
content = sanitizer.SanitizePartial(content)