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 == "" {