From 5efcbdf3e52f3bdd35632ae23587df13b46ec5f7 Mon Sep 17 00:00:00 2001 From: yutianjiang39 <245600294+yutianjiang39@users.noreply.github.com> Date: Sun, 29 Nov 2026 08:59:16 +0000 Subject: [PATCH] fix: align compact ComputerUse mode guidance with foreground policy --- src/crates/assembly/core/Cargo.toml | 4 +++ .../implementations/computer_use_tool.rs | 3 +- .../core/tests/computer_use_schema.rs | 32 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 src/crates/assembly/core/tests/computer_use_schema.rs diff --git a/src/crates/assembly/core/Cargo.toml b/src/crates/assembly/core/Cargo.toml index 881a24db4d..9d29766eda 100644 --- a/src/crates/assembly/core/Cargo.toml +++ b/src/crates/assembly/core/Cargo.toml @@ -494,6 +494,10 @@ openbitfun-runtime-services = { path = "../../execution/runtime-services", featu tempfile = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread", "test-util"] } +[[test]] +name = "computer_use_schema" +required-features = ["agent-runtime", "tools-computer-use"] + [[test]] name = "git_contracts" required-features = ["git"] diff --git a/src/crates/assembly/core/src/agentic/tools/implementations/computer_use_tool.rs b/src/crates/assembly/core/src/agentic/tools/implementations/computer_use_tool.rs index df76d19e15..da687378a6 100644 --- a/src/crates/assembly/core/src/agentic/tools/implementations/computer_use_tool.rs +++ b/src/crates/assembly/core/src/agentic/tools/implementations/computer_use_tool.rs @@ -663,8 +663,7 @@ Use ExecCommand for genuine shell work, never ad hoc GUI capture, clipboard or i let properties = schema["properties"].as_object_mut().unwrap(); properties["app"]["description"] = json!("Known app from list_apps, or exact {pid,window_id} from list_windows on window-target-v1 hosts. Omit to keep the bound window. Use list_windows when the title is wrong or a helper has no window."); - properties["mode"]["description"] = - json!("Default background. Foreground only for a user-requested takeover."); + properties["mode"]["description"] = json!("Default background. Use foreground for the requested GUI task when background delivery is unsupported or verified ineffective, unless the user required background-only/no-disruption."); properties["ms"]["description"] = json!("wait duration. With app or a bound window, returns that window's observation after waiting; no separate get_app_state is needed."); properties["query"]["description"] = json!("list_windows: case-insensitive match on application name, bundle id or title across processes (finds helper processes too); includes off-screen windows."); properties["include_offscreen"]["description"] = json!("list_windows: also list minimized/hidden/other-Space windows. Default false unfiltered (counted per app), true with app/query."); diff --git a/src/crates/assembly/core/tests/computer_use_schema.rs b/src/crates/assembly/core/tests/computer_use_schema.rs new file mode 100644 index 0000000000..fd79f73f0b --- /dev/null +++ b/src/crates/assembly/core/tests/computer_use_schema.rs @@ -0,0 +1,32 @@ +#![cfg(all(feature = "agent-runtime", feature = "tools-computer-use"))] + +use openbitfun_core::agentic::tools::{ + framework::{Tool, ToolUseContext}, + implementations::ComputerUseTool, +}; + +#[tokio::test] +async fn compact_mode_describes_conditional_foreground_for_gui_tasks() { + let tool = ComputerUseTool::new(); + let mut text_only = ToolUseContext::for_tool_listing(None, None); + text_only.primary_model_facts.supports_image_inputs = false; + + for schema in [ + tool.input_schema_for_model().await, + tool.input_schema_for_model_with_context(Some(&text_only)) + .await, + ] { + let mode = schema["properties"]["mode"]["description"] + .as_str() + .expect("compact mode description"); + for clause in [ + "Default background", + "Use foreground for the requested GUI task", + "unsupported or verified ineffective", + "unless the user required background-only/no-disruption", + ] { + assert!(mode.contains(clause), "missing {clause:?} in {mode:?}"); + } + assert!(!mode.contains("user-requested takeover"), "{mode}"); + } +}