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(presentation): validate resolved bus spec instead of raw input
Steven Enamakel3a34067ba235
diff --git a/crates/openhuman-core/src/tools/impl/presentation/mod.rs b/crates/openhuman-core/src/tools/impl/presentation/mod.rsindex c885e62ef8..be4d640f11 100644--- a/crates/openhuman-core/src/tools/impl/presentation/mod.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/mod.rs@@ -2,9 +2,9 @@//! structured slide spec via the native-Rust [`engine`] module.//!//! Flow:-//! 1. Validate the JSON-Schema input early (`types::validate_input`)-//! so the agent gets a structured `InvalidInput` it can self-correct-//! on instead of a low-level error.+//! 1. Validate host-owned image references, resolve readable images, then+//! validate the resolved bus spec so the agent gets a structured+//! `InvalidInput` it can self-correct on before artifact production.//! 2. Start a [`Production`]: it reserves `<title>.pptx` in the files folder//! (the card shows "generating…") and opens the versioned artifact — or,//! with an `artifact_id` arg or a regenerate in scope, a new version of@@ -47,11 +47,12 @@ mod types;#[path = "presentation_tests.rs"]mod tests;-use crate::tools::implementations::document::format::spec::SlideImage;+use tinydocs_bus::spec::SlideImage;use self::types::{- validate_input, GeneratePresentationInput, GeneratePresentationOutput, SlideImageRequest,- SlideImageSource, MAX_IMAGE_BYTES,+ to_bus_spec, validate_image_references, GeneratePresentationInput,+ GeneratePresentationOutput, PresentationError, SlideImageRequest, SlideImageSource,+ MAX_IMAGE_BYTES,};/// Generation timeout. `ppt-rs` typically completes the full 64-slide@@ -332,19 +333,11 @@ impl PresentationTool {}};- if let Err(err) = validate_input(&input) {+ if let Err(err) = validate_image_references(&input) {tracing::debug!(target: "presentation", err = %err, "[presentation] validation rejected input");return Ok(ToolResult::error(err.to_string()));}- tracing::info!(- target: "presentation",- title_chars = input.title.chars().count(),- has_author = input.author.is_some(),- slide_count = input.slides.len(),- "[presentation] generation request accepted"- );-// Resolve + validate per-slide images at the async boundary. A// bad image is skipped with a warning (partial success) rather// than failing the whole deck — mirrors the #3076 ethos.@@ -357,6 +350,23 @@ impl PresentationTool {);}+ let spec = match to_bus_spec(&input, &resolved_images) {+ Ok(spec) => spec,+ Err(err) => return Ok(ToolResult::error(err.to_string())),+ };+ if let Err(err) = spec.validate().map_err(PresentationError::from) {+ tracing::debug!(target: "presentation", err = %err, "[presentation] validation rejected input");+ return Ok(ToolResult::error(err.to_string()));+ }++ tracing::info!(+ target: "presentation",+ title_chars = input.title.chars().count(),+ has_author = input.author.is_some(),+ slide_count = input.slides.len(),+ "[presentation] generation request accepted"+ );+// Reserve the file and open the artifact: a new one, or a new version// of `artifact_id` / the regenerate target (same id, same file,// history kept).diff --git a/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs b/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rsindex 33137f5022..fe2eb091fc 100644--- a/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs+++ b/crates/openhuman-core/src/tools/impl/presentation/presentation_tests.rs@@ -178,7 +178,8 @@ fn resolved_presentation_uses_bus_validation_and_preserves_its_limit_error() {}).collect(),};- let spec = super::types::to_bus_spec(&input, vec![Vec::new(); input.slides.len()]);+ let images = vec![Vec::new(); input.slides.len()];+ let spec = super::types::to_bus_spec(&input, &images).expect("one image list per slide");let error = spec.validate().expect_err("the bus slide limit is enforced");let error = PresentationError::from(error);@@ -388,7 +389,7 @@ async fn image_inspection_does_not_fall_back_when_modules_are_disabled() {}]})).expect("parse presentation input");- validate_input(&input).expect("valid presentation input");+ validate_image_references(&input).expect("valid host image reference");let (resolved, warnings) = tool.resolve_images(&input, &DispatchCtx::ambient()).await;assert!(resolved.iter().all(Vec::is_empty));@@ -453,18 +454,23 @@ async fn execute_skips_missing_artifact_with_warning() {async fn execute_rejects_too_many_images_per_deck() {let ws = workspace();let tool = make_tool(ws.path());- // 9 images total across slides — exceeds the deck cap of 8. This is a- // hard validation reject (cheap structural check), not a skip.+ let image_path = ws.path().join("one.png");+ std::fs::write(&image_path, png_1x1()).expect("write valid image");+ // Nine successfully resolved images exceed the bus deck cap of eight.let images: Vec<_> = (0..9)- .map(|i| json!({ "source": { "type": "artifact", "artifact_id": format!("a{i}") } }))+ .map(|_| json!({ "source": { "type": "file", "path": image_path.to_string_lossy() } })).collect();let args = json!({"title": "Deck","slides": [{ "title": "Slide", "bullets": ["x"], "images": images }]});let result = tool.execute(args).await.expect("execute returns Ok");- assert!(result.is_error, "9 images should be rejected outright");- assert!(result.text().contains("images"));+ assert!(result.is_error, "9 resolved images should exceed the bus limit");+ assert!(+ result.text().contains("must contain ≤ 8 images total"),+ "the tool should preserve the bus limit in its error: {}",+ result.text()+ );}#[test]