mirror of
https://github.com/openai/codex.git
synced 2026-10-28 18:58:46 +00:00
Fix guardian handoff mocks for native history tests (#57468)
## What changed Add mock guardian approvals for setup handoffs in `handoff_scenario` when native multi-agent history is enabled. Match only the trailing `function_call_output` so historical handoffs cannot consume the final command's separate denial response. Require five approval requests with native history enabled and none with it disabled. GitOrigin-RevId: 7b14c97aa85adc63c4d3bf95014c44831eae1c85
This commit is contained in:
@@ -89,6 +89,39 @@ pub(crate) async fn handoff_scenario(native_history: bool) -> Result<Vec<Respons
|
||||
.await?;
|
||||
let root = test.session_configured.thread_id;
|
||||
let mut created = test.thread_manager.subscribe_thread_created();
|
||||
// Allow the setup handoffs. Match the trailing native evidence output so
|
||||
// historical calls cannot swallow the final command's separate denial.
|
||||
wiremock::Mock::given(wiremock::matchers::method("POST"))
|
||||
.and(wiremock::matchers::path("/v1/responses"))
|
||||
.and(|request: &wiremock::Request| {
|
||||
request_body(request).is_some_and(|body| {
|
||||
body["client_metadata"]["x-openai-subagent"] == "guardian"
|
||||
&& body["input"]
|
||||
.as_array()
|
||||
.and_then(|items| items.last())
|
||||
.is_some_and(|item| {
|
||||
item["type"] == "function_call_output"
|
||||
&& matches!(
|
||||
item["call_id"].as_str(),
|
||||
Some(
|
||||
"spawn-alpha" | "spawn-leaf" | "spawn-beta" | "send-alpha"
|
||||
| "followup-alpha"
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
.respond_with(sse_response(sse(vec![
|
||||
ev_assistant_message(
|
||||
"handoff-allow",
|
||||
r#"{"risk_level":"low","user_authorization":"high","outcome":"allow","rationale":"Mock approval for the scenario handoff."}"#,
|
||||
),
|
||||
ev_completed("handoff-allow"),
|
||||
])))
|
||||
.with_priority(/*p*/ 1)
|
||||
.expect(if native_history { 5 } else { 0 })
|
||||
.mount(&server)
|
||||
.await;
|
||||
// Ordinary root/worker continuations idle; the reviewed action has its own mock.
|
||||
wiremock::Mock::given(wiremock::matchers::method("POST"))
|
||||
.and(wiremock::matchers::path("/v1/responses"))
|
||||
|
||||
Reference in New Issue
Block a user