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(tests): replace delegation-guard tests with search-bridge tests
Steven Enamakelf7fe3029e6bc
diff --git a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rsindex f04ae523eb..554ff5462c 100644--- a/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs+++ b/crates/openhuman-core/src/agent/registry/agents/orchestrator/prompt_tests.rs@@ -280,9 +280,11 @@ fn build_includes_direct_first_decision_tree() {assert!(body.contains("Take the first branch that applies:"));assert!(body.contains("**Answerable without tools**: reply."));// Step 2 of the decision tree routes live external-service requests to- // `delegate_to_integrations_agent` rather than memory.+ // a `tool_search` + direct call rather than memory or a sub-agent.assert!(body.contains("Needs a connected service's own data or actions"));assert!(body.contains("Use the live service even when memory could plausibly answer"));+ assert!(body.contains("there is no integrations sub-agent"));+ assert!(!body.contains("delegate_to_integrations_agent"));}#[test]@@ -312,7 +314,7 @@ fn build_routes_code_repo_work_to_run_code_tool() {}#[test]-fn build_emits_delegation_guide_with_collapsed_tool() {+fn build_emits_connected_integrations_as_search_then_call() {let integrations = vec![ConnectedIntegration {toolkit: "gmail".into(),description: "Email access.".into(),@@ -324,18 +326,22 @@ fn build_emits_delegation_guide_with_collapsed_tool() {}];let body = build(&ctx_with(&integrations)).unwrap();assert!(body.contains("## Connected Integrations"));- assert!(body.contains("delegate_to_integrations_agent"));assert!(body.contains("toolkit: \"gmail\""));- // Must NOT contain the old per-toolkit fan-out tool names.+ // The route is the harness's search bridge, not a sub-agent.+ assert!(body.contains("`tool_search` for the action"));+ assert!(body.contains("no sub-agent"));+ // The removed delegate and the old per-toolkit fan-out must be gone.+ assert!(!body.contains("delegate_to_integrations_agent"));assert!(!body.contains("delegate_gmail"));- // Must NOT contain the old verbose spawn_subagent snippet.+ assert!(!body.contains("integrations_agent"));assert!(!body.contains("spawn_subagent(agent_id=\"integrations_agent\""));- // Delegator voice must NOT use the skill-executor wording.+ // The "you have direct access" skill-executor wording stays out: the+ // actions are not on the wire, they are searchable.assert!(!body.contains("You have direct access"));- // Must keep the always-delegate contract for real service asks.+ // Must keep the always-try contract for real service asks.assert!(- body.contains("Never claim you cannot access one without delegating first"),- "delegation guide must instruct the model to always attempt delegation"+ body.contains("Never claim you cannot access one without searching first"),+ "the block must instruct the model to search before refusing");}@@ -343,13 +349,13 @@ fn build_emits_delegation_guide_with_collapsed_tool() {fn build_scope_gates_integrations_delegation() {// Regression: a connected service (e.g. Gmail) is not, by itself, a// reason to operate on it — a general-knowledge / web / date ask that- // names no service must NOT spawn `delegate_to_integrations_agent`.+ // names no service must NOT reach for a service action.// Guards both the static Step-2 scope gate and the rendered- // delegation-guide clause.+ // connected-integrations clause.let no_integrations = build(&ctx_with(&[])).unwrap();assert!(- no_integrations.contains("general knowledge, web/news lookups, headlines, date/time and math never delegate here"),- "Step-2 scope gate must keep general/web/date asks off integrations delegation"+ no_integrations.contains("general knowledge, web/news lookups, headlines, date/time and math never go to a service"),+ "Step-2 scope gate must keep general/web/date asks off integration actions");assert!(no_integrations.contains("A service being connected is not a reason to touch it"),@@ -369,10 +375,10 @@ fn build_scope_gates_integrations_delegation() {assert!(with_gmail.contains("a connected service is not a reason to touch it for general-knowledge"),- "delegation guide must carry the scoping clause when integrations are connected"+ "connected-integrations block must carry the scoping clause when integrations are connected");- // The existing always-delegate contract for real service asks is preserved.- assert!(with_gmail.contains("Never claim you cannot access one without delegating first"));+ // The existing always-try contract for real service asks is preserved.+ assert!(with_gmail.contains("Never claim you cannot access one without searching first"));}#[test]@@ -383,29 +389,10 @@ fn build_does_not_route_scope_errors_as_disconnected() {// connectable list.assert!(body.contains("If the connect call reports the toolkit unavailable, relay its message"));assert!(body.contains("that is the only honest refusal"));- assert!(body.contains("the list shows what is connected, not what is connectable"));+ assert!(body.contains("shows what is connected, not what is connectable"));assert!(body.contains("`composio_connect`"));}-#[test]-fn delegation_guide_uses_compact_collapsed_format() {- let integrations = vec![ConnectedIntegration {- toolkit: "gmail".into(),- description: "Email access.".into(),- tools: Vec::new(),- gated_tools: Vec::new(),- connected: true,- connections: Vec::new(),- non_active_status: None,- }];- let body = build(&ctx_with(&integrations)).unwrap();- assert!(body.contains("## Connected Integrations"));- assert!(body.contains("delegate_to_integrations_agent"));- // Old verbose / per-toolkit forms must be gone.- assert!(!body.contains("delegate_gmail"));- assert!(!body.contains("spawn_subagent(agent_id=\"integrations_agent\""));-}-fn gmail_only() -> Vec<ConnectedIntegration> {vec![ConnectedIntegration {toolkit: "gmail".into(),@@ -418,66 +405,54 @@ fn gmail_only() -> Vec<ConnectedIntegration> {}]}-// Regression for #4361: on local providers (`native_tool_calling = false`-// → PFormat/Json dispatcher) the whole tool catalogue is prose and weak-// models mis-route trivial requests through the integrations delegate-// ("Ciao" → Connections, "create a folder on Desktop" → Calendar). The-// delegation guide must add an explicit non-delegation carve-out for those-// text-protocol providers.+// The block is the same for every dispatcher. The text-protocol "When NOT to+// delegate" carve-out (#4361) guarded a delegate tool that no longer exists;+// the scoping clause in the block body carries that rule for every format.#[test]-fn delegation_guide_adds_local_guardrail_for_text_protocol() {- let integrations = gmail_only();- for format in [ToolCallFormat::PFormat, ToolCallFormat::Json] {- let guide = render_delegation_guide(&integrations, format);- assert!(- guide.contains("### When NOT to delegate"),- "text-protocol ({format:?}) guide must carve out non-integration work"- );- // The two reported failure modes are named explicitly.- assert!(- guide.contains("create a folder on the Desktop"),- "guardrail must keep local folder/file actions off delegation ({format:?})"- );- assert!(- guide.to_ascii_lowercase().contains("greetings"),- "guardrail must keep greetings off delegation ({format:?})"- );- // Additive: the always-delegate contract for real service requests- // is preserved — the guardrail narrows, it does not remove it.- assert!(- guide.contains("Never claim you cannot access one without delegating first"),- "always-delegate contract must remain for genuine service asks ({format:?})"- );- }+fn connected_integrations_block_is_format_independent() {+ let guide = render_connected_integrations(&gmail_only());+ assert!(guide.contains("## Connected Integrations"));+ assert!(guide.contains("`tool_search` for the action"));+ assert!(!guide.contains("### When NOT to delegate"));+ assert!(guide.contains("a connected service is not a reason to touch it"));+ assert!(guide.contains("Never claim you cannot access one without searching first"));}-// Native structured-tool-calling providers (cloud) keep the historic guide-// byte-for-byte: no over-delegation problem, so no carve-out.+// Capability questions are answered from the searchable catalogue, never+// from priors and never by spawning a worker to look.#[test]-fn delegation_guide_omits_local_guardrail_for_native() {- let guide = render_delegation_guide(&gmail_only(), ToolCallFormat::Native);- assert!(guide.contains("## Connected Integrations"));- assert!(- !guide.contains("### When NOT to delegate"),- "native providers must keep the delegation guide unchanged"- );- assert!(guide.contains("Never claim you cannot access one without delegating first"));+fn connected_integrations_block_routes_capability_questions_to_search() {+ let guide = render_connected_integrations(&gmail_only());+ assert!(guide.contains("### Capability questions about connected toolkits"));+ assert!(guide.contains("`tool_search` first"));+ assert!(!guide.contains("integrations_agent"));}-// With no connected integrations the section is omitted for every format —-// the guardrail must never resurrect an otherwise-empty block.+// Pref-gated actions are not searchable, so the block lists them with their+// unlock paths — the appendix that used to live in the integrations+// sub-agent's prompt.#[test]-fn delegation_guide_empty_without_connections_for_all_formats() {- for format in [- ToolCallFormat::PFormat,- ToolCallFormat::Json,- ToolCallFormat::Native,- ] {- assert!(- render_delegation_guide(&[], format).is_empty(),- "empty connections must omit the section ({format:?})"- );- }+fn connected_integrations_block_lists_gated_actions_with_unlock_paths() {+ let mut integrations = gmail_only();+ integrations[0].gated_tools = vec![crate::agent::prompts::GatedIntegrationTool {+ name: "GMAIL_DELETE_MESSAGE".into(),+ description: "Delete a message".into(),+ required_scope: "delete".into(),+ unlock_paths: vec!["Connections → Gmail → Delete".into()],+ }];+ let guide = render_connected_integrations(&integrations);+ assert!(guide.contains("### Additional capabilities behind a permission toggle"));+ assert!(guide.contains("`GMAIL_DELETE_MESSAGE` — Delete a message (requires `delete` scope)"));+ assert!(guide.contains("unlock path: Connections → Gmail → Delete"));++ let without = render_connected_integrations(&gmail_only());+ assert!(!without.contains("### Additional capabilities behind a permission toggle"));+}++// With no connected integrations the section is omitted.+#[test]+fn connected_integrations_block_empty_without_connections() {+ assert!(render_connected_integrations(&[]).is_empty());}#[test]