Skip to content

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

fix(attachments): preserve url sources in history fallback blocks

Steven Enamakel5c6633f2f69d
diff --git a/crates/openhuman-core/src/attachments/provider_owner.rs b/crates/openhuman-core/src/attachments/provider_owner.rs
index 1575ec3bec..881a6f9d25 100644
--- a/crates/openhuman-core/src/attachments/provider_owner.rs
+++ b/crates/openhuman-core/src/attachments/provider_owner.rs
@@ -228,8 +228,8 @@ impl MediaFallbackCache<AttachmentAccessScope> for AttachmentModel {
}
impl MediaHistoryFallback<AttachmentAccessScope> for AttachmentModel {
- fn omitted(&self, scope: &AttachmentAccessScope, _modality: InputModality, source: &str) -> String {
- let block = ContentBlock::Document(MediaRef::Path { path: source.to_owned(), media_type: None });
+ fn omitted(&self, scope: &AttachmentAccessScope, modality: InputModality, source: &str) -> String {
+ let block = history_source_block(modality, source);
let hint = super::historical_source_hint(&block, scope);
format!("[Earlier attachment omitted by history budget; workspace path: {hint}]")
}
@@ -248,17 +248,43 @@ impl MediaHistoryFallback<AttachmentAccessScope> for AttachmentModel {
{
return None;
}
- let block = match modality {
- InputModality::Image => ContentBlock::Image(ImageRef { url: source.to_owned(), mime_type: None }),
- InputModality::Audio => ContentBlock::Audio(MediaRef::Path { path: source.to_owned(), media_type: None }),
- InputModality::Video => ContentBlock::Video(MediaRef::Path { path: source.to_owned(), media_type: None }),
- InputModality::Document => ContentBlock::Document(MediaRef::Path { path: source.to_owned(), media_type: None }),
- };
+ let block = history_source_block(modality, source);
let hint = super::historical_source_hint(&block, scope);
Some(format!("[Earlier attachment unavailable or omitted at workspace path: {hint}]") )
}
}
+fn history_source_block(modality: InputModality, source: &str) -> ContentBlock {
+ match modality {
+ InputModality::Image => ContentBlock::Image(ImageRef {
+ url: source.to_owned(),
+ mime_type: None,
+ }),
+ modality => {
+ let media = if source.starts_with("data:")
+ || source.starts_with("http://")
+ || source.starts_with("https://")
+ {
+ MediaRef::Url {
+ url: source.to_owned(),
+ media_type: None,
+ }
+ } else {
+ MediaRef::Path {
+ path: source.to_owned(),
+ media_type: None,
+ }
+ };
+ match modality {
+ InputModality::Audio => ContentBlock::Audio(media),
+ InputModality::Video => ContentBlock::Video(media),
+ InputModality::Document => ContentBlock::Document(media),
+ InputModality::Image => unreachable!(),
+ }
+ }
+ }
+}
+
struct OwnedDocumentsExtractor {
ctx: Option<std::sync::Weak<crate::core::runtime::CoreContext>>,
}