Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(raw_coverage): pass turn context to approval gate calls

Steven Enamakel181e01c1db9a
diff --git a/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs b/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
index b8a2b87c35..5ec61e75a4 100644
--- a/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/tool_registry_approval_raw_coverage_e2e.rs
@@ -693,25 +693,26 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
request_id: None,
},
async move {
- let turn = ApprovalTurnContext::chat(ApprovalChatContext {
+ let turn = ApprovalTurnContext::chat(ApprovalChatContext {
thread_id: "approval-raw-thread".to_string(),
client_id: "approval-raw-client".to_string(),
// No turn in scope in this fixture; the field is documented as
// carried only when the caller has one (`gate.rs:91-95`).
request_id: None,
});
- gate_for_task
- .intercept_audited(&turn,
- "tools.composio_execute",
- "tools.composio_execute(action=execute, 123 bytes)",
- json!({
- "action": "execute",
- "tool_slug": "GMAIL_SEND_EMAIL",
- "body": "<redacted: string (500 chars)>"
- }),
- )
- .await
- },
+ gate_for_task
+ .intercept_audited(
+ &turn,
+ "tools.composio_execute",
+ "tools.composio_execute(action=execute, 123 bytes)",
+ json!({
+ "action": "execute",
+ "tool_slug": "GMAIL_SEND_EMAIL",
+ "body": "<redacted: string (500 chars)>"
+ }),
+ )
+ .await
+ },
)
.await
});
@@ -834,6 +835,7 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
// caller that forgot to scope a label.
let no_chat = gate
.intercept_audited(
+ &Default::default(),
"tools.web_search",
"tools.web_search(query=coverage)",
json!({ "query": "coverage" }),
@@ -854,6 +856,7 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
);
assert!(matches!(
gate.intercept(
+ &Default::default(),
"tools.web_search",
"tools.web_search(query=legacy)",
json!({ "query": "legacy" }),
@@ -883,6 +886,7 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
request_id: None,
},
gate.intercept_audited(
+ &Default::default(),
"tools.composio_execute",
"tools.composio_execute(action=execute)",
json!({ "action": "execute" }),
@@ -907,17 +911,19 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
config.workspace_dir.clone(),
config.workspace_dir.clone(),
);
- let live_policy_auto_approved = gate.intercept_audited(&ApprovalTurnContext::chat(ApprovalChatContext {
+ let live_policy_auto_approved = gate
+ .intercept_audited(
+ &ApprovalTurnContext::chat(ApprovalChatContext {
thread_id: "approval-live-policy-thread".to_string(),
client_id: "approval-live-policy-client".to_string(),
// No turn in scope in this fixture; the field is documented as
// carried only when the caller has one (`gate.rs:91-95`).
request_id: None,
- }),
- "tools.live_policy_allowed",
- "tools.live_policy_allowed(action=coverage)",
- json!({ "action": "coverage" }),
- )
+ }),
+ "tools.live_policy_allowed",
+ "tools.live_policy_allowed(action=coverage)",
+ json!({ "action": "coverage" }),
+ )
.await;
assert!(matches!(live_policy_auto_approved.0, GateOutcome::Allow));
assert_eq!(live_policy_auto_approved.1, None);
@@ -934,21 +940,22 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
request_id: None,
},
async move {
- let turn = ApprovalTurnContext::chat(ApprovalChatContext {
+ let turn = ApprovalTurnContext::chat(ApprovalChatContext {
thread_id: "approval-deny-thread".to_string(),
client_id: "approval-deny-client".to_string(),
// No turn in scope in this fixture; the field is documented as
// carried only when the caller has one (`gate.rs:91-95`).
request_id: None,
});
- gate_for_deny_task
- .intercept_audited(&turn,
- "tools.web_search",
- "tools.web_search(query=deny)",
- json!({ "query": "deny" }),
- )
- .await
- },
+ gate_for_deny_task
+ .intercept_audited(
+ &turn,
+ "tools.web_search",
+ "tools.web_search(query=deny)",
+ json!({ "query": "deny" }),
+ )
+ .await
+ },
)
.await
});
@@ -1057,17 +1064,18 @@ async fn approval_rpc_decision_paths_persist_always_allow_and_recent_audit() {
client_id: "approval-persist-failure-client".to_string(),
request_id: None,
},
- gate.intercept_audited(&ApprovalTurnContext::chat(ApprovalChatContext {
+ gate.intercept_audited(
+ &ApprovalTurnContext::chat(ApprovalChatContext {
thread_id: "approval-persist-failure-thread".to_string(),
client_id: "approval-persist-failure-client".to_string(),
// No turn in scope in this fixture; the field is documented as
// carried only when the caller has one (`gate.rs:91-95`).
request_id: None,
- }),
- "tools.persistence_failure",
- "tools.persistence_failure(action=coverage)",
- json!({ "action": "coverage" }),
- ),
+ }),
+ "tools.persistence_failure",
+ "tools.persistence_failure(action=coverage)",
+ json!({ "action": "coverage" }),
+ ),
)
.await;
match persist_failure.0 {
diff --git a/tests/raw_coverage/worker_b_raw_coverage_e2e.rs b/tests/raw_coverage/worker_b_raw_coverage_e2e.rs
index 19259fbcb2..d031b814cc 100644
--- a/tests/raw_coverage/worker_b_raw_coverage_e2e.rs
+++ b/tests/raw_coverage/worker_b_raw_coverage_e2e.rs
@@ -610,21 +610,22 @@ async fn approval_gate_rpc_decision_resumes_parked_tool_and_records_execution()
request_id: None,
},
async move {
- let turn = ApprovalTurnContext::chat(ApprovalChatContext {
+ let turn = ApprovalTurnContext::chat(ApprovalChatContext {
thread_id: "worker-b-thread".to_string(),
client_id: "worker-b-client".to_string(),
// No turn in scope in this fixture; the field is documented as
// carried only when the caller has one (`gate.rs:91-95`).
request_id: None,
});
- gate_for_task
- .intercept_audited(&turn,
- "tools.web_search",
- "search the web for coverage",
- json!({ "query": "<redacted>", "max_results": 3 }),
- )
- .await
- },
+ gate_for_task
+ .intercept_audited(
+ &turn,
+ "tools.web_search",
+ "search the web for coverage",
+ json!({ "query": "<redacted>", "max_results": 3 }),
+ )
+ .await
+ },
)
.await
});