MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_turn_message

Function build_turn_message

atomic-agent/src/record/message.rs:27–63  ·  view source on GitHub ↗

Build the change message for a turn. Message priority: 1. If the prompt is meaningful (not a slash command, not too short), use it directly — the user's intent is the best commit message. 2. Generate a descriptive message from the actual file changes (e.g., "Add CLAUDE.md" or "Modify auth.rs; add test_auth.rs"). 3. Extract a wrap-up summary from the agent's transcript — but ONLY text that appears

(
    options: &TurnRecordOptions<'_>,
    status: &RepositoryStatus,
    untracked_paths: &[String],
)

Source from the content-addressed store, hash-verified

25/// in the SessionEnvelope metadata and `atomic log` can render it from there.
26/// The change message should describe *what changed*, not bookkeeping.
27pub(crate) fn build_turn_message(
28 options: &TurnRecordOptions<'_>,
29 status: &RepositoryStatus,
30 untracked_paths: &[String],
31) -> String {
32 // Priority 1: If we have a meaningful prompt, use it directly.
33 // The user typed something like "Fix the auth bug" — that's the best
34 // description of intent. Slash commands (/init, /help) are filtered out.
35 if let Some(prompt) = &options.prompt {
36 if is_meaningful_prompt(prompt) {
37 return truncate_prompt(prompt, 72);
38 }
39 }
40
41 // Priority 2: Generate a message from the actual file changes.
42 // This is always accurate and concrete: "Add CLAUDE.md" or
43 // "Modify auth.rs; add test_auth.rs, utils.rs (+3 more)".
44 let file_summary = build_file_change_summary(status, untracked_paths);
45 if !file_summary.is_empty() {
46 return truncate_prompt(&file_summary, 72);
47 }
48
49 // Priority 3: Try the transcript as a last resort.
50 // Only use assistant text that appears AFTER the last tool call —
51 // that's Claude's wrap-up summary, not its opening analysis/planning.
52 if let Some(ref transcript_path) = options.session.transcript_path {
53 if let Some(summary) = summarize_from_transcript(transcript_path) {
54 return truncate_prompt(&summary, 72);
55 }
56 }
57
58 // Priority 4: Last resort
59 format!(
60 "Turn {} ({})",
61 options.turn_number, options.session.agent_display_name
62 )
63}
64
65/// Extract a one-line commit message from the agent's transcript file.
66///

Calls 5

is_meaningful_promptFunction · 0.85
truncate_promptFunction · 0.70
is_emptyMethod · 0.45