The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(agent): delegate user content block conversion to runtime
Steven Enamakele35119b33a89
diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rsindex dbdb28b2e8..45fa3311bb 100644--- a/crates/openhuman-core/src/agent/message_convert.rs+++ b/crates/openhuman-core/src/agent/message_convert.rs@@ -166,82 +166,7 @@ fn user_content_blocks(text: String) -> Vec<ContentBlock> {return user.content;}}-- const PREFIX: &str = "[IMAGE:";- // Fast path: no markers → unchanged single text block (byte-for-byte).- if !text.contains(PREFIX) {- return vec![ContentBlock::Text(text)];- }-- fn flush_text(pending: &mut String, blocks: &mut Vec<ContentBlock>) {- let trimmed = pending.trim();- if !trimmed.is_empty() {- blocks.push(ContentBlock::Text(trimmed.to_string()));- }- pending.clear();- }-- let mut blocks: Vec<ContentBlock> = Vec::new();- let mut pending = String::new();- let mut images = 0usize;- let mut rest = text.as_str();-- while let Some(start) = rest.find(PREFIX) {- pending.push_str(&rest[..start]);- let after = &rest[start + PREFIX.len()..];- let Some(end) = after.find(']') else {- // Unterminated marker — keep the remainder verbatim as text.- pending.push_str(&rest[start..]);- rest = "";- break;- };- let payload = after[..end].trim();- if is_provider_ready_image_reference(payload) {- // Preserve source order: flush the prose seen so far, then the image.- flush_text(&mut pending, &mut blocks);- blocks.push(ContentBlock::Image(ImageRef {- url: payload.to_string(),- mime_type: data_uri_mime(payload),- }));- images += 1;- } else {- // Not provider-ready (bare path / un-normalized marker) — keep the- // whole `[IMAGE:…]` marker verbatim as text.- pending.push_str(&rest[start..start + PREFIX.len() + end + 1]);- }- rest = &after[end + 1..];- }- pending.push_str(rest);- flush_text(&mut pending, &mut blocks);-- if images > 0 {- log::debug!(- "[agent][message_convert] lifted {images} image attachment(s) from user text into content blocks"- );- }- // A whitespace-only, image-less remainder still needs a block to stay a- // valid user turn.- if blocks.is_empty() {- blocks.push(ContentBlock::Text(text));- }- blocks-}--/// A nonempty legacy image reference. Local paths remain typed and are-/// resolved under host policy on the ephemeral provider request.-fn is_provider_ready_image_reference(reference: &str) -> bool {- !reference.trim().is_empty()-}--/// Extract the MIME type from a `data:<mime>;base64,…` URI, if present.-///-/// Best-effort: the provider layer also reads the type straight from the `data:`-/// URI, so a non-`data:` reference (e.g. an `http(s)` URL) simply carries-/// `None` and is forwarded as-is.-fn data_uri_mime(reference: &str) -> Option<String> {- let rest = reference.strip_prefix("data:")?;- let mime = rest.split([';', ',']).next()?.trim();- (!mime.is_empty()).then(|| mime.to_string())+ tinyagents_runtime::transcript::user_content_blocks(text)}/// Rebuild a harness [`TaToolCall`] from a row's [`TranscriptToolCall`] (whose