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
feat(presentation): validate request metadata before resolving images
Steven Enamakeld86f5659738e
diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rsindex de8fca752b..2c81a468db 100644--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs@@ -50,7 +50,7 @@ mod tests;use tinydocs_bus::spec::SlideImage;use self::types::{- to_bus_spec, validate_image_references, GeneratePresentationInput, GeneratePresentationOutput,+ to_bus_spec, validate_image_references, validate_request, GeneratePresentationInput, GeneratePresentationOutput,PresentationError, SlideImageRequest, SlideImageSource, MAX_IMAGE_BYTES,};@@ -332,7 +332,7 @@ impl PresentationTool {}};- if let Err(err) = validate_image_references(&input) {+ if let Err(err) = validate_request(&input).and_then(|()| validate_image_references(&input)) {tracing::debug!(target: "presentation", err = %err, "[presentation] validation rejected input");return Ok(ToolResult::error(err.to_string()));}@@ -349,7 +349,7 @@ impl PresentationTool {);}- let spec = match to_bus_spec(&input, &resolved_images) {+ let spec = match to_bus_spec(&input, resolved_images) {Ok(spec) => spec,Err(err) => return Ok(ToolResult::error(err.to_string())),};@@ -404,7 +404,7 @@ impl PresentationTool {let bytes = match engine::generate(&input,- &resolved_images,+ &spec,GENERATION_TIMEOUT,self.config.as_ref(),)diff --git a/crates/openhuman-core/src/tools/impl/presentation/types.rs b/crates/openhuman-core/src/tools/impl/presentation/types.rsindex 3cfcfe3821..d005fb7756 100644--- a/crates/openhuman-core/src/tools/impl/presentation/types.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/types.rs@@ -1,7 +1,7 @@//! Typed input / output / error contracts for the `generate_presentation` tool.use serde::{Deserialize, Serialize};-use tinydocs_bus::spec::presentation::{PresentationSpec, SlideSpec};+use tinydocs_bus::spec::presentation::{PresentationRequestSpec, PresentationSpec, SlideRequestSpec, SlideSpec};use crate::modules::documents::DocumentCallError;@@ -221,9 +221,26 @@ impl From<tinydocs_bus::Error> for PresentationError {}}+/// Validate source-agnostic request metadata before the host resolves image+/// references. Each requested image is represented by its caption, including+/// images whose host-side reference will later fail to resolve.+pub(super) fn validate_request(input: &GeneratePresentationInput) -> Result<(), PresentationError> {+ let request = PresentationRequestSpec {+ title: input.title.clone(),+ author: input.author.clone(),+ theme: input.theme.clone(),+ slides: input.slides.iter().map(|slide| SlideRequestSpec {+ title: slide.title.clone(),+ body: slide.body.clone(),+ bullets: slide.bullets.clone(),+ speaker_notes: slide.speaker_notes.clone(),+ images: slide.images.iter().map(|image| image.caption.clone()).collect(),+ }).collect(),+ };+ request.validate().map_err(PresentationError::from)+}+/// Reject empty host-owned image references before attempting to resolve them.-/// The shared bus validator owns all content and image-field limits once the-/// host has resolved usable image bytes.pub(super) fn validate_image_references(input: &GeneratePresentationInput,) -> Result<(), PresentationError> {@@ -253,7 +270,7 @@ pub(super) fn validate_image_references(/// Project tool input and host-resolved image bytes onto the owner bus contract.pub(super) fn to_bus_spec(input: &GeneratePresentationInput,- resolved_images: &[Vec<tinydocs_bus::spec::SlideImage>],+ resolved_images: Vec<Vec<tinydocs_bus::spec::SlideImage>>,) -> Result<PresentationSpec, PresentationError> {if input.slides.len() != resolved_images.len() {return Err(PresentationError::InvalidInput {@@ -271,7 +288,7 @@ pub(super) fn to_bus_spec(body: slide.body.clone(),bullets: slide.bullets.clone(),speaker_notes: slide.speaker_notes.clone(),- images: images.clone(),+ images,}).collect();