Change summary
internal/agent/agent.go | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Detailed changes
@@ -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 <think> tags from generated titles.
+var thinkTagRegex = regexp.MustCompile(`<think>.*?</think>`)
+
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, "</think>"); idx > 0 {
- title = title[idx+len("</think>"):]
- }
+ title = thinkTagRegex.ReplaceAllString(title, "")
title = strings.TrimSpace(title)
if title == "" {