Skip to content

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

feat(attachments): accept mime hint when resolving media

Steven Enamakeld2889013fdf7
diff --git a/crates/openhuman-core/src/attachments/provider_owner.rs b/crates/openhuman-core/src/attachments/provider_owner.rs
index 4c9bbb9932..ac40752a14 100644
--- a/crates/openhuman-core/src/attachments/provider_owner.rs
+++ b/crates/openhuman-core/src/attachments/provider_owner.rs
@@ -58,20 +58,32 @@ impl MediaSourceResolver<AttachmentAccessScope> for AttachmentModel {
modality: InputModality,
source: &str,
max_bytes: usize,
+ ) -> Result<ResolvedMedia, String> {
+ self.resolve_with_mime_hint(scope, modality, source, max_bytes, None)
+ .await
+ }
+
+ async fn resolve_with_mime_hint(
+ &self,
+ scope: &AttachmentAccessScope,
+ modality: InputModality,
+ source: &str,
+ max_bytes: usize,
+ mime_hint: Option<&str>,
) -> Result<ResolvedMedia, String> {
let block = match modality {
InputModality::Image => ContentBlock::Image(ImageRef {
url: source.to_owned(),
- mime_type: None,
+ mime_type: mime_hint.map(str::to_owned),
}),
InputModality::Audio | InputModality::Video | InputModality::Document => {
let media = if source.starts_with("data:")
|| source.starts_with("http://")
|| source.starts_with("https://")
{
- MediaRef::Url { url: source.to_owned(), media_type: None }
+ MediaRef::Url { url: source.to_owned(), media_type: mime_hint.map(str::to_owned) }
} else {
- MediaRef::Path { path: source.to_owned(), media_type: None }
+ MediaRef::Path { path: source.to_owned(), media_type: mime_hint.map(str::to_owned) }
};
match modality {
InputModality::Audio => ContentBlock::Audio(media),
@@ -97,6 +109,10 @@ impl MediaSourceResolver<AttachmentAccessScope> for AttachmentModel {
None,
))
.ok_or_else(|| "image attachment type cannot be determined".to_string())?;
+ } else if let Some(mime_hint) = mime_hint {
+ // Typed per-block metadata is authoritative for that reference.
+ // Marker references pass no hint and retain source detection.
+ mime = mime_hint.to_owned();
} else if mime == "application/octet-stream" {
mime = tinyagents_harness::multimodal::mime::detect_file_mime(
Some(std::path::Path::new(&path)),