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

Function normalize_user_prompt

atomic-agent/src/hooks/grok.rs:312–328  ·  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

310/// would show the tags. Extract the inner text when the envelope is present;
311/// leave plain prompts untouched.
312fn normalize_user_prompt(prompt: &str) -> String {
313 let trimmed = prompt.trim();
314
315 // Prefer a complete open/close pair (multiline body supported).
316 const OPEN: &str = "<user_query>";
317 const CLOSE: &str = "</user_query>";
318 if let Some(start) = trimmed.find(OPEN) {
319 let after_open = &trimmed[start + OPEN.len()..];
320 if let Some(end) = after_open.find(CLOSE) {
321 return after_open[..end].trim().to_string();
322 }
323 // Open tag without close — take everything after the open tag.
324 return after_open.trim().to_string();
325 }
326
327 trimmed.to_string()
328}
329
330fn with_xai_provider(mut raw: Value) -> Value {
331 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