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: fail closed on media reference refresh errors
Steven Enamakel83fa14050bde
diff --git a/crates/openhuman-core/src/agent/registry/agents/image_agent/agent.toml b/crates/openhuman-core/src/agent/registry/agents/image_agent/agent.tomlindex 816c660b78..65c8a21fca 100644--- a/crates/openhuman-core/src/agent/registry/agents/image_agent/agent.toml+++ b/crates/openhuman-core/src/agent/registry/agents/image_agent/agent.toml@@ -1,7 +1,7 @@id = "image_agent"display_name = "Image Creator"delegate_name = "create_image"-when_to_use = "Image-generation specialist: create images from a prompt, or edit/restyle a reference image. Route make/generate/draw/edit-an-image requests here. Saves each result to the workspace and returns the local path."+when_to_use = "Image-generation specialist: create images from a prompt, or edit/restyle a reference image. Route make/generate/draw/edit-an-image requests here. Saves each result to the configured Files folder and returns its local path; paths from earlier media calls there can be reused as references."temperature = 0.6max_iterations = 8agent_tier = "worker"diff --git a/crates/openhuman-core/src/agent/registry/agents/image_agent/prompt.md b/crates/openhuman-core/src/agent/registry/agents/image_agent/prompt.mdindex f5b1465f90..3391023b82 100644--- a/crates/openhuman-core/src/agent/registry/agents/image_agent/prompt.md+++ b/crates/openhuman-core/src/agent/registry/agents/image_agent/prompt.md@@ -11,7 +11,8 @@ images you generate.- **Create** images from a text prompt (`media_generate_image`).- **Edit / restyle** a supplied image by passing it in `references` (https- URLs, `data:` URLs, or workspace file paths).+ URLs, `data:` URLs, workspace file paths, or the absolute path returned by an+ earlier image/video call in the configured Files folder).- **Pick the right model** when it matters — call `media_list_models`(`kind: "image"`, optional `search`) to see the catalog. The default suitsmost requests.@@ -27,8 +28,9 @@ images you generate.matter. `n` asks for several variants; `seed` makes a result reproducible.- For edits, pass the source image(s) in `references` and describe the changeprecisely.-- Each generation **saves the image to the Files folder and returns a local file- path**. Always report that path back so the deck/answer can reference the+- Each generation **saves the image to the configured Files folder and returns+ a local file path**. That absolute path can be reused in `references` on a+ later call. Always report it back so the deck/answer can reference theconcrete artifact. Do not paste raw base64 or invent URLs.- Generation is billed. Don't loop on near-identical prompts — generate, inspectthe result, and only re-run if it materially misses the brief.diff --git a/crates/openhuman-core/src/agent/registry/agents/video_agent/agent.toml b/crates/openhuman-core/src/agent/registry/agents/video_agent/agent.tomlindex db35054405..c7a6e54f99 100644--- a/crates/openhuman-core/src/agent/registry/agents/video_agent/agent.toml+++ b/crates/openhuman-core/src/agent/registry/agents/video_agent/agent.toml@@ -1,7 +1,7 @@id = "video_agent"display_name = "Video Creator"delegate_name = "create_video"-when_to_use = "Video-generation specialist: short clips from a prompt, or animate a supplied image. Route make/generate-a-video and animate-this-image requests here. Takes a few minutes, then saves the clip and returns the local path."+when_to_use = "Video-generation specialist: short clips from a prompt, or animate a supplied image. Route make/generate-a-video and animate-this-image requests here. Takes a few minutes, then saves the clip to the configured Files folder and returns its local path; paths from earlier media calls there can be reused as frames or references."temperature = 0.6max_iterations = 8agent_tier = "worker"diff --git a/crates/openhuman-core/src/agent/registry/agents/video_agent/prompt.md b/crates/openhuman-core/src/agent/registry/agents/video_agent/prompt.mdindex dc622c8162..6b481e43f7 100644--- a/crates/openhuman-core/src/agent/registry/agents/video_agent/prompt.md+++ b/crates/openhuman-core/src/agent/registry/agents/video_agent/prompt.md@@ -11,7 +11,9 @@ can do text-to-video or animate a supplied first-frame/reference image- **Create** a clip from a text prompt (`media_generate_video`).- **Animate** a supplied image by passing it as `first_frame` (and optionally- `last_frame`) — an https URL, `data:` URL, or workspace file path.+ `last_frame`) — an https URL, `data:` URL, workspace file path, or the+ absolute path returned by an earlier image/video call in the configured+ Files folder. The same path can be supplied under `references`.- **Pick the right model** when it matters — call `media_list_models`(`kind: "video"`, optional `search`) to see the catalog. The fast defaultsuits most requests.@@ -29,9 +31,9 @@ can do text-to-video or animate a supplied first-frame/reference imagemotion you want applied to it. `references` guide subject or style withoutfixing a frame.- Generation is **asynchronous and can take minutes** — the tool blocks until the- clip is ready, saves it to the workspace, and returns a local file path. Report- that path back. Set expectations: tell the delegating agent it may take a- little while.+ clip is ready, saves it to the configured Files folder, and returns a local+ file path. That absolute path can be reused in later media calls. Report it+ back. Set expectations: tell the delegating agent it may take a little while.- Generation is billed and slow. Don't re-run on near-identical prompts — onlyiterate if the result materially misses the brief.diff --git a/crates/openhuman-core/src/media/generation/artifact_tool.rs b/crates/openhuman-core/src/media/generation/artifact_tool.rsindex dd74e33d4d..c9a85a60fb 100644--- a/crates/openhuman-core/src/media/generation/artifact_tool.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool.rs@@ -364,10 +364,12 @@ impl<T: Tool> MediaArtifactTool<T> {};let mut recovered = std::collections::HashSet::new();- let previously_allowed = allowed- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner)- .clone();+ let previously_allowed = {+ let mut allowed = allowed+ .lock()+ .unwrap_or_else(std::sync::PoisonError::into_inner);+ std::mem::take(&mut *allowed)+ };let artifacts = match crate::agent::artifacts::store::list_artifacts(&self.workspace_dir,0,diff --git a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rsindex 1b42f8ee0a..c65bd31022 100644--- a/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs+++ b/crates/openhuman-core/src/media/generation/artifact_tool_tests.rs@@ -8,6 +8,7 @@ use tinytools::{PermissionLevel, Tool, ToolCategory, ToolContent, ToolResult};use super::{copy_blob_to_file, has_reusable_files_reference, MediaArtifactTool};use crate::agent::artifacts::{ArtifactKind, ArtifactStatus, FileRoots};+use crate::media::generation::tools::reference_policy;#[test]fn artifact_history_is_refreshed_only_for_absolute_paths_in_files_roots() {@@ -36,6 +37,38 @@ fn artifact_history_is_refreshed_only_for_absolute_paths_in_files_roots() {));}+#[tokio::test]+async fn artifact_history_refresh_failure_clears_previous_reference_grants() {+ let root = tempfile::tempdir().unwrap();+ let workspace = root.path().join("not-a-workspace-directory");+ std::fs::write(&workspace, b"force artifact listing failure").unwrap();+ let action = root.path().join("action");+ let files = root.path().join("Files");+ std::fs::create_dir_all(&action).unwrap();+ std::fs::create_dir_all(&files).unwrap();+ let replacement = files.join("generated.png");+ std::fs::write(&replacement, b"unrelated replacement").unwrap();+ let allowed = Arc::new(std::sync::Mutex::new(std::collections::HashSet::from([+ replacement.clone(),+ ])));+ let tool = MediaArtifactTool::new(+ StubMediaTool {+ file_count: 0,+ fail: false,+ },+ ArtifactKind::Image,+ workspace.clone(),+ files,+ )+ .with_reference_allowlist(Arc::clone(&allowed));++ tool.refresh_allowed_references().await;++ assert!(allowed.lock().unwrap().is_empty());+ let policy = reference_policy(&action, &workspace, allowed);+ assert!(policy(&replacement).is_err());+}+struct PartialThenFail(bool);impl tokio::io::AsyncRead for PartialThenFail {