@@ -16,6 +16,7 @@ import (
17 "log/slog"
17 "log/slog"
@@ -45,6 +46,9 @@ var titlePrompt []byte
45//go:embed templates/summary.md
46//go:embed templates/summary.md
46var summaryPrompt []byte
47var summaryPrompt []byte
49+// Used to remove <think> tags from generated titles.
50+var thinkTagRegex = regexp.MustCompile(`<think>.*?</think>`)
48type SessionAgentCall struct {
52type SessionAgentCall struct {
49 SessionID string
53 SessionID string
50 Prompt string
54 Prompt string
@@ -760,9 +764,7 @@ func (a *sessionAgent) generateTitle(ctx context.Context, sessionID string, prom
760 title = strings.ReplaceAll(title, "\n", " ")
764 title = strings.ReplaceAll(title, "\n", " ")
762 // Remove thinking tags if present.
766 // Remove thinking tags if present.
763− if idx := strings.Index(title, "</think>"); idx > 0 {
767+ title = thinkTagRegex.ReplaceAllString(title, "")
764− title = title[idx+len("</think>"):]
767 title = strings.TrimSpace(title)
769 title = strings.TrimSpace(title)
768 if title == "" {
770 if title == "" {