getCompactUserSummaryMessage function

String getCompactUserSummaryMessage(
  1. String summary, {
  2. bool suppressFollowUpQuestions = false,
  3. String? transcriptPath,
  4. bool recentMessagesPreserved = false,
})

Get the compact user summary message content.

Implementation

String getCompactUserSummaryMessage(
  String summary, {
  bool suppressFollowUpQuestions = false,
  String? transcriptPath,
  bool recentMessagesPreserved = false,
}) {
  final formattedSummary = formatCompactSummary(summary);

  var baseSummary =
      'This session is being continued from a previous conversation that ran out of context. '
      'The summary below covers the earlier portion of the conversation.\n\n'
      '$formattedSummary';

  if (transcriptPath != null) {
    baseSummary +=
        '\n\nIf you need specific details from before compaction, '
        'read the full transcript at: $transcriptPath';
  }

  if (recentMessagesPreserved) {
    baseSummary += '\n\nRecent messages are preserved verbatim.';
  }

  if (suppressFollowUpQuestions) {
    return '$baseSummary\n'
        'Continue the conversation from where it left off without asking the user any further questions. '
        'Resume directly -- do not acknowledge the summary, do not recap what was happening, '
        'do not preface with "I\'ll continue" or similar. Pick up the last task as if the break never happened.';
  }

  return baseSummary;
}