Skip to content

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

feat(attachments): allow resolving attachments from committed history

Steven Enamakelf4cb9dbc0a93
diff --git a/crates/openhuman-core/src/agent/attachments/provider.rs b/crates/openhuman-core/src/agent/attachments/provider.rs
index c03cd0ce41..52e53059cb 100644
--- a/crates/openhuman-core/src/agent/attachments/provider.rs
+++ b/crates/openhuman-core/src/agent/attachments/provider.rs
@@ -266,7 +266,10 @@ impl AttachmentModel {
)));
continue;
}
- let resolved = match self.resolve_block(&block, &scope).await {
+ let resolved = match self
+ .resolve_block(&block, &scope, Some(message_index) != latest_user_message)
+ .await
+ {
Ok(resolved) => resolved,
Err(error)
if Some(message_index) != latest_user_message
diff --git a/crates/openhuman-core/src/agent/attachments/provider_source.rs b/crates/openhuman-core/src/agent/attachments/provider_source.rs
index dd46c04669..1e239d1ced 100644
--- a/crates/openhuman-core/src/agent/attachments/provider_source.rs
+++ b/crates/openhuman-core/src/agent/attachments/provider_source.rs
@@ -12,6 +12,7 @@ impl AttachmentModel {
&self,
block: &ContentBlock,
scope: &AttachmentAccessScope,
+ allow_committed_history: bool,
) -> tinyinference_llm::Result<Option<(InputModality, String, String, Vec<u8>, bool)>> {
let (modality, source, mime, is_local) = match block {
ContentBlock::Image(image) => (
@@ -37,6 +38,7 @@ impl AttachmentModel {
thread_id,
opaque_id,
&scope.native_staged_parts,
+ allow_committed_history,
)
.await
.map_err(tinyinference_llm::Error::Model)?;
diff --git a/crates/openhuman-core/src/threads/attachments/staged.rs b/crates/openhuman-core/src/threads/attachments/staged.rs
index 4499041e56..92dff25fa7 100644
--- a/crates/openhuman-core/src/threads/attachments/staged.rs
+++ b/crates/openhuman-core/src/threads/attachments/staged.rs
@@ -419,6 +419,7 @@ pub(crate) async fn read_authorized_native_attachment(
thread_id: &str,
opaque_id: &str,
current_parts: &[ContentPart],
+ allow_committed_history: bool,
) -> Result<ResolvedNativeAttachment, String> {
let id = staged_doc_id(opaque_id)?;
let tenant = tenant_for(ctx)?;
@@ -442,7 +443,7 @@ pub(crate) async fn read_authorized_native_attachment(
&& claim.thread_id == thread_id
&& claim.part == record.attachment.part
});
- if !current_authority && !committed_authority {
+ if !current_authority && !(allow_committed_history && committed_authority) {
return Err("native attachment lacks a current or committed host grant".into());
}
let entries = vec![record.attachment.clone()];