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

Function normalize_user_prompt

atomic-agent/src/hooks/grok.rs:369–385  ·  view source on GitHub ↗

Strip Grok harness wrappers from a user prompt. Grok's agent runtime delivers the human message inside an XML-ish envelope: ```text Make sure this project runs. ``` Atomic records that string as the turn's change message, so `atomic log` would show the tags. Extract the inner text when the envelope is present; leave plain prompts untouched.

(prompt: &str)

Source from the content-addressed store, hash-verified

367/// would show the tags. Extract the inner text when the envelope is present;
368/// leave plain prompts untouched.
369fn normalize_user_prompt(prompt: &str) -> String {
370 let trimmed = prompt.trim();
371
372 // Prefer a complete open/close pair (multiline body supported).
373 const OPEN: &str = "<user_query>";
374 const CLOSE: &str = "</user_query>";
375 if let Some(start) = trimmed.find(OPEN) {
376 let after_open = &trimmed[start + OPEN.len()..];
377 if let Some(end) = after_open.find(CLOSE) {
378 return after_open[..end].trim().to_string();
379 }
380 // Open tag without close — take everything after the open tag.
381 return after_open.trim().to_string();
382 }
383
384 trimmed.to_string()
385}
386
387fn with_xai_provider(mut raw: Value) -> Value {
388 if let Some(obj) = raw.as_object_mut() {

Callers 1

parse_eventMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected