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
refactor(attachments): share the delegated config/scope resolution (#7714)
M3gA-Mind2f21fc0610ed
diff --git a/crates/openhuman-core/src/agent/attachments/mod.rs b/crates/openhuman-core/src/agent/attachments/mod.rsindex 6e6e1f3739..03fa715112 100644--- a/crates/openhuman-core/src/agent/attachments/mod.rs+++ b/crates/openhuman-core/src/agent/attachments/mod.rs@@ -424,6 +424,27 @@ pub(crate) async fn stage(Ok(out)}+/// Config and scope for a delegated reference: the explicit workspace, else+/// the thread's folder, which is where the turn staged its uploads (#7714).+async fn acting_config(+ workspace: Option<&tinytools::WorkspaceDescriptor>,+ thread_id: Option<&str>,+) -> anyhow::Result<(Config, AttachmentAccessScope)> {+ let mut config = crate::config::rpc::load_config_with_timeout()+ .await+ .map_err(anyhow::Error::msg)?;+ let action_dir = match workspace {+ Some(workspace) => workspace.root.clone(),+ None => thread_action_dir(&config, &config.workspace_dir, thread_id).await?,+ };+ config.action_dir = action_dir;+ let scope = AttachmentAccessScope {+ external_channel: false,+ workspace: workspace.map(|workspace| workspace.root.clone()),+ };+ Ok((config, scope))+}+/// Explicit image forwarding for delegation. A filename mentioned in prose/// grants no read; only the typed argument or a legacy image marker does.pub(crate) async fn delegation_prompt(@@ -455,21 +476,7 @@ pub(crate) async fn delegation_prompt() {anyhow::bail!("local attachment reads are disabled for external channel input");}- let mut config = crate::config::rpc::load_config_with_timeout()- .await- .map_err(anyhow::Error::msg)?;- if let Some(workspace) = workspace {- config.action_dir = workspace.root.clone();- } else {- // No explicit workspace: the turn acts in its thread's folder, so the- // copy must land (and be checked) there too (#7714).- let dir = thread_action_dir(&config, &config.workspace_dir, thread_id).await?;- config.action_dir = dir;- }- let scope = AttachmentAccessScope {- external_channel: false,- workspace: workspace.map(|workspace| workspace.root.clone()),- };+ let (config, scope) = acting_config(workspace, thread_id).await?;stage(&prompt, "delegation", &config, &scope).await}@@ -493,27 +500,13 @@ pub(crate) async fn has_resolvable_image(if paths.is_empty() {return Ok(false);}- let mut config = crate::config::rpc::load_config_with_timeout()- .await- .map_err(anyhow::Error::msg)?;if matches!(origin,Some(crate::agent::turn_origin::AgentTurnOrigin::ExternalChannel { .. })) {anyhow::bail!("local attachment reads are disabled for external channel input");}- if let Some(workspace) = workspace {- config.action_dir = workspace.root.clone();- } else {- // No explicit workspace: the turn acts in its thread's folder, so its- // uploads are resolved there too (#7714).- let dir = thread_action_dir(&config, &config.workspace_dir, thread_id).await?;- config.action_dir = dir;- }- let scope = AttachmentAccessScope {- external_channel: false,- workspace: workspace.map(|workspace| workspace.root.clone()),- };+ let (config, scope) = acting_config(workspace, thread_id).await?;for path in paths {let path = legacy::migrate_path(&config, &path, &scope).await?diff --git a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rsindex aa65bb10b3..7933e0f472 100644--- a/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs+++ b/crates/openhuman-core/src/agent/attachments/mod_access_tests.rs@@ -149,6 +149,10 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {};thread_in(&config, "bound", Some(&folder)).await;thread_in(&config, "unbound", None).await;+ let gone = temp.path().join("gone");+ std::fs::create_dir_all(&gone).unwrap();+ thread_in(&config, "gone", Some(&gone)).await;+ std::fs::remove_dir(&gone).unwrap();let root = thread_action_dir(&config, &config.workspace_dir, Some("bound")).await@@ -162,6 +166,13 @@ async fn thread_folder_upload_is_staged_where_the_turn_reads_it() {config.action_dir);}+ // A folder that disappeared is an error, as in `run_task`, not a silent+ // fallback to the global dir.+ assert!(+ thread_action_dir(&config, &config.workspace_dir, Some("gone"))+ .await+ .is_err()+ );// Stage the way `start_chat` does, then read the way the turn does: its// config acts in the thread folder and the request scope names nodiff --git a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rsindex 3485d5c066..ca59d0c171 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/dispatch.rs@@ -255,9 +255,7 @@ pub(crate) async fn dispatch_subagent_with_live_parent(prompt,parent_workspace_descriptor.as_ref(),run_context.origin.as_ref(),- tool_context- .and_then(ToolRunContext::thread_id)- .or(run_context.thread_id.as_deref()),+ run_context.thread_id.as_deref(),).await{