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

Function extract_user_content

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

Extract user content from a transcript message value.

(message: &serde_json::Value)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 3

getMethod · 0.65
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected