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
fix(attachments): enforce attachment limits and cleanup on failure
Steven Enamakelb92a80a62550
diff --git a/crates/openhuman-core/src/agent/attachments/provider.rs b/crates/openhuman-core/src/agent/attachments/provider.rsindex 52e53059cb..204869497d 100644--- a/crates/openhuman-core/src/agent/attachments/provider.rs+++ b/crates/openhuman-core/src/agent/attachments/provider.rs@@ -221,7 +221,8 @@ impl AttachmentModel {.count();let (max_images, _) = self.config.multimodal.effective_limits();let (max_files, _, _) = self.config.multimodal_files.effective_limits();- if images > max_images+ if (self.config.multimodal.max_images == 0 && images > 0)+ || images > max_images|| files > max_files|| self.config.multimodal_files.max_files == 0 && images + files > 0{diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rsindex 5acf5d6ef7..73bf68c06e 100644--- a/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs+++ b/crates/openhuman-core/src/channels/runtime/dispatch/native_runner.rs@@ -575,6 +575,8 @@ pub(crate) async fn run(}};runtime.shared.begin_delivery_wait(&request_id);+ let cleanup_staged_parts = staged_parts.clone();+ let cleanup_config = trusted.host_agent.config.clone();let request = TurnRequest {scope: ScopeKey {agent_id: trusted.host_agent.definition.id.clone(),@@ -603,6 +605,18 @@ pub(crate) async fn run(Err(tinyagents_harness::turn_runner::TurnRunnerError::Queued));let result = runner_result.map_err(|error| error.to_string());+ if !queued && result.is_err() && !cleanup_staged_parts.is_empty() {+ if let Err(error) = crate::threads::attachments::discard_native_channel_parts(+ dispatch,+ &thread_id,+ &cleanup_config,+ &cleanup_staged_parts,+ )+ .await+ {+ tracing::warn!("[channels::dispatch] failed to clean rejected native media staging");+ }+ }if queued {runtime.shared.abandon_delivery_wait(&request_id);}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.rsindex a5021cab5d..5ba4877ea4 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@@ -78,7 +78,7 @@ pub(super) async fn resolve_typed_message(_ => {}}}- if image_count > max_images {+ if (config.multimodal.max_images == 0 && image_count > 0) || image_count > max_images {return Err("native image attachments exceed their count limit".into());}if file_count > max_files {@@ -174,7 +174,27 @@ pub(super) async fn resolve_typed_message(staged_parts.push(staged);}- let message = crate::agent::message_convert::user_message_from_parts(enriched_message, &parts)?;+ let model_parts = parts+ .iter()+ .filter(|part| matches!(part, ContentPart::Image { .. } | ContentPart::File { .. }))+ .cloned()+ .collect::<Vec<_>>();+ let message = match crate::agent::message_convert::user_message_from_parts(+ enriched_message,+ &model_parts,+ ) {+ Ok(message) => message,+ Err(error) => {+ let _ = crate::threads::attachments::discard_native_channel_parts(+ host_dispatch,+ thread_id,+ config,+ &staged_parts,+ )+ .await;+ return Err(error);+ }+ };Ok(Some(ResolvedNativeMessage {message,staged_parts,