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

Function extract_user_content

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

Extract user content from a transcript message value.

(message: &serde_json::Value)

Source from the content-addressed store, hash-verified

165
166/// Extract user content from a transcript message value.
167fn extract_user_content(message: &serde_json::Value) -> Option<String> {
168 // User content can be a string or an array of content blocks
169 if let Some(s) = message.get("content").and_then(|c| c.as_str()) {
170 if !s.is_empty() {
171 return Some(s.to_string());
172 }
173 }
174 if let Some(arr) = message.get("content").and_then(|c| c.as_array()) {
175 for item in arr {
176 if let Some(text) = item.get("text").and_then(|t| t.as_str()) {
177 if !text.is_empty() {
178 return Some(text.to_string());
179 }
180 }
181 // Also handle plain string items in the array
182 if let Some(text) = item.as_str() {
183 if !text.is_empty() {
184 return Some(text.to_string());
185 }
186 }
187 }
188 }
189 // Direct string message
190 if let Some(s) = message.as_str() {
191 if !s.is_empty() {
192 return Some(s.to_string());
193 }
194 }
195 None
196}
197
198/// Extract appropriate detail for a tool call.
199///

Callers 1

Calls 3

getMethod · 0.65
as_strMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected