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

Method set_first_prompt

atomic-agent/src/turn/session.rs:319–339  ·  view source on GitHub ↗

Set the first prompt if not already set. Truncates to MAX_PROMPT_LENGTH. Also updates `current_prompt` on every call so the change message reflects this turn's intent, not the session's opening prompt.

(&mut self, prompt: &str)

Source from the content-addressed store, hash-verified

317 /// Also updates `current_prompt` on every call so the change message
318 /// reflects this turn's intent, not the session's opening prompt.
319 pub fn set_first_prompt(&mut self, prompt: &str) {
320 if prompt.is_empty() {
321 return;
322 }
323
324 let stored = if prompt.len() <= Self::MAX_PROMPT_LENGTH {
325 prompt.to_string()
326 } else {
327 let truncated: String = prompt.chars().take(Self::MAX_PROMPT_LENGTH - 3).collect();
328 format!("{}...", truncated)
329 };
330
331 // first_prompt is set-once (preserves the session's opening prompt)
332 if self.first_prompt.is_none() {
333 self.first_prompt = Some(stored.clone());
334 }
335
336 // current_prompt is updated every turn so the change message
337 // reflects THIS turn's intent, not the session's opening prompt.
338 self.current_prompt = Some(stored);
339 }
340
341 /// Add files to the accumulated files_touched list (deduplicating).
342 pub fn add_files_touched(&mut self, files: &[String]) {

Calls 4

is_noneMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45