@@ -561,15 +561,7 @@ func (a *sessionAgent) Summarize(ctx context.Context, sessionID string, opts fan
561561 return err
562562 }
563563
564− summaryPromptText := "Provide a detailed summary of our conversation above."
565− if len(currentSession.Todos) > 0 {
566− summaryPromptText += "\n\n## Current Todo List\n\n"
567− for _, t := range currentSession.Todos {
568− summaryPromptText += fmt.Sprintf("- [%s] %s\n", t.Status, t.Content)
569− }
570− summaryPromptText += "\nInclude these tasks and their statuses in your summary. "
571− summaryPromptText += "Instruct the resuming assistant to use the `todos` tool to continue tracking progress on these tasks."
572− }
564+ summaryPromptText := buildSummaryPrompt(currentSession.Todos)
573565
574566 resp, err := agent.Stream(genCtx, fantasy.AgentStreamCall{
575567 Prompt: summaryPromptText,
@@ -1101,3 +1093,18 @@ func (a *sessionAgent) workaroundProviderMediaLimitations(messages []fantasy.Mes
11011093
11021094 return convertedMessages
11031095}
1096+
1097+// buildSummaryPrompt constructs the prompt text for session summarization.
1098+func buildSummaryPrompt(todos []session.Todo) string {
1099+ var sb strings.Builder
1100+ sb.WriteString("Provide a detailed summary of our conversation above.")
1101+ if len(todos) > 0 {
1102+ sb.WriteString("\n\n## Current Todo List\n\n")
1103+ for _, t := range todos {
1104+ fmt.Fprintf(&sb, "- [%s] %s\n", t.Status, t.Content)
1105+ }
1106+ sb.WriteString("\nInclude these tasks and their statuses in your summary. ")
1107+ sb.WriteString("Instruct the resuming assistant to use the `todos` tool to continue tracking progress on these tasks.")
1108+ }
1109+ return sb.String()
1110+}