MCPcopy Create free account
hub / github.com/AI45Lab/Code / task_child_run_permission_deny

Function task_child_run_permission_deny

core/src/tools/task.rs:2057–2098  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2055
2056 #[tokio::test]
2057 async fn task_child_run_permission_deny() {
2058 let workspace = tempfile::tempdir().unwrap();
2059 let registry = AgentRegistry::new();
2060 let spec = crate::subagent::WorkerAgentSpec::custom("restricted", "Restricted agent")
2061 .with_permissions(PermissionPolicy::new().allow("read(*)").deny("bash(*)"))
2062 .with_max_steps(3);
2063 registry.register(spec.into_agent_definition());
2064
2065 let mock = Arc::new(MockLlmClient::new(vec![
2066 MockLlmClient::tool_call_response(
2067 "t1",
2068 "bash",
2069 serde_json::json!({"command": "echo hello"}),
2070 ),
2071 MockLlmClient::text_response("Could not run bash."),
2072 ]));
2073
2074 let executor = TaskExecutor::new(
2075 Arc::new(registry),
2076 mock,
2077 workspace.path().to_string_lossy().to_string(),
2078 );
2079
2080 let result = executor
2081 .execute(
2082 TaskParams {
2083 agent: "restricted".to_string(),
2084 description: "Try bash".to_string(),
2085 prompt: "Run echo hello".to_string(),
2086 background: false,
2087 max_steps: Some(3),
2088 },
2089 None,
2090 None,
2091 )
2092 .await
2093 .unwrap();
2094
2095 // The agent completes (LLM responds after denial), but bash was denied.
2096 // The denial is sent as a tool result to the LLM, which then responds.
2097 assert!(result.success, "agent should complete: {}", result.output);
2098 }
2099
2100 #[tokio::test]
2101 async fn task_child_run_confirmation_auto_approve() {

Callers

nothing calls this directly

Calls 8

with_permissionsMethod · 0.80
denyMethod · 0.80
allowMethod · 0.80
into_agent_definitionMethod · 0.80
pathMethod · 0.80
with_max_stepsMethod · 0.45
registerMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected