From c49b4fe243ffd6b9ded5afdc53c9e85e0dff404c Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sun, 28 Dec 2025 07:04:29 -0800 Subject: [PATCH] fix(sessions): tag removal, handle multibyte --- internal/agent/agent.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 65655a21385baa5d98926ed62ba89ba0aac2c539..00deaabecb7bae9068b40ed8cb8be78707520797 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -16,6 +16,7 @@ import ( "fmt" "log/slog" "os" + "regexp" "strconv" "strings" "sync" @@ -45,6 +46,9 @@ var titlePrompt []byte //go:embed templates/summary.md var summaryPrompt []byte +// Used to remove tags from generated titles. +var thinkTagRegex = regexp.MustCompile(`.*?`) + type SessionAgentCall struct { SessionID string Prompt string @@ -760,9 +764,7 @@ func (a *sessionAgent) generateTitle(ctx context.Context, sessionID string, prom title = strings.ReplaceAll(title, "\n", " ") // Remove thinking tags if present. - if idx := strings.Index(title, ""); idx > 0 { - title = title[idx+len(""):] - } + title = thinkTagRegex.ReplaceAllString(title, "") title = strings.TrimSpace(title) if title == "" {