package agent import ( "strings" ) type ParsedResponse struct { Reasoning string Content string } func ParseResponse(raw string) ParsedResponse { tags := []struct { open string close string }{ {"", ""}, {"", ""}, {"", ""}, {"", ""}, {"", ""}, } for _, t := range tags { if t.open == "" { break } idxOpen := strings.Index(raw, t.open) idxClose := strings.LastIndex(raw, t.close) if idxOpen != -1 && idxClose != -1 && idxClose > idxOpen { reasoning := raw[idxOpen+len(t.open) : idxClose] content := raw[:idxOpen] + raw[idxClose+len(t.close):] return ParsedResponse{ Reasoning: strings.TrimSpace(reasoning), Content: strings.TrimSpace(content), } } } return ParsedResponse{Content: strings.TrimSpace(raw)} }