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

Function extract_user_content

atomic-agent/src/transcript/condense.rs:261–290  ·  view source on GitHub ↗

Extract user content from a transcript message value.

(message: &serde_json::Value)

Source from the content-addressed store, hash-verified

259
260/// Extract user content from a transcript message value.
261fn extract_user_content(message: &serde_json::Value) -> Option<String> {
262 // User content can be a string or an array of content blocks
263 if let Some(s) = message.get("content").and_then(|c| c.as_str()) {
264 if !s.is_empty() {
265 return Some(s.to_string());
266 }
267 }
268 if let Some(arr) = message.get("content").and_then(|c| c.as_array()) {
269 for item in arr {
270 if let Some(text) = item.get("text").and_then(|t| t.as_str()) {
271 if !text.is_empty() {
272 return Some(text.to_string());
273 }
274 }
275 // Also handle plain string items in the array
276 if let Some(text) = item.as_str() {
277 if !text.is_empty() {
278 return Some(text.to_string());
279 }
280 }
281 }
282 }
283 // Direct string message
284 if let Some(s) = message.as_str() {
285 if !s.is_empty() {
286 return Some(s.to_string());
287 }
288 }
289 None
290}
291
292/// Extract appropriate detail for a tool call.
293///

Callers 1

Calls 3

getMethod · 0.65
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected