Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(core): support enriched message in native media resolution

Steven Enamakel14e5bd39b6fe
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
index c7e03eaae1..9517bb90c7 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/native_media.rs
@@ -34,6 +34,7 @@ pub(super) async fn resolve_typed_message(
config: &crate::config::Config,
envelope: &ChannelInboundEnvelope,
thread_id: &str,
+ enriched_message: &str,
) -> Result<Option<ResolvedNativeMessage>, String> {
if !requires_typed_preparation(envelope) {
return Ok(None);
@@ -143,17 +144,34 @@ pub(super) async fn resolve_typed_message(
&bytes,
)
.await?;
- *part = staged.clone();
+ let opaque_id = media_opaque_id(&staged)
+ .ok_or_else(|| "staged native media has no host reference".to_owned())?;
+ let mut model_part = staged.clone();
+ let model_media = match &mut model_part {
+ ContentPart::Image { media, .. } | ContentPart::File { media, .. } => media,
+ _ => return Err("native staged media kind changed unexpectedly".into()),
+ };
+ model_media.path = Some(format!("openhuman-staged://{opaque_id}"));
+ *part = model_part;
staged_parts.push(staged);
}
- let message = crate::agent::message_convert::user_message_from_parts("", &parts)?;
+ let message = crate::agent::message_convert::user_message_from_parts(enriched_message, &parts)?;
Ok(Some(ResolvedNativeMessage {
message,
staged_parts,
}))
}
+fn media_opaque_id(part: &ContentPart) -> Option<&str> {
+ match part {
+ ContentPart::Image { media, .. } | ContentPart::File { media, .. } => {
+ media.opaque_id.as_deref()
+ }
+ _ => None,
+ }
+}
+
pub(super) struct ResolvedNativeMessage {
pub(super) message: Message,
pub(super) staged_parts: Vec<ContentPart>,
diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rs
index 48fbc85ec6..d8b3f77346 100644
--- a/crates/openhuman-core/src/threads/attachments/staged.rs
+++ b/crates/openhuman-core/src/threads/attachments/staged.rs
@@ -336,7 +336,7 @@ pub(crate) async fn stage_native_channel_part(
.ok_or_else(|| "native attachment kind cannot be staged".to_owned())?;
let opaque_id = uuid::Uuid::new_v4().simple().to_string();
media.opaque_id = Some(opaque_id.clone());
- media.path = Some(format!("openhuman-staged://{opaque_id}"));
+ media.path = None;
media.url = None;
media.local_cache_path = None;
media.content_type = Some(file.mime.clone());