From e96e2a44735f1e4ae61ecb5408e3b6c38533d0df Mon Sep 17 00:00:00 2001 From: Abhinav Vedmala Date: Wed, 20 May 2026 14:39:42 -0700 Subject: [PATCH] Remove stale plan hook exclusions --- codex-rs/core/tests/suite/hooks.rs | 139 ----------------------------- 1 file changed, 139 deletions(-) diff --git a/codex-rs/core/tests/suite/hooks.rs b/codex-rs/core/tests/suite/hooks.rs index eebe91014c..eb06734a33 100644 --- a/codex-rs/core/tests/suite/hooks.rs +++ b/codex-rs/core/tests/suite/hooks.rs @@ -3056,75 +3056,6 @@ async fn pre_tool_use_blocks_apply_patch_with_write_alias() -> Result<()> { Ok(()) } -#[tokio::test] -async fn pre_tool_use_blocks_plan_tool() -> Result<()> { - skip_if_no_network!(Ok(())); - - let server = start_mock_server().await; - let call_id = "pretooluse-update-plan"; - let args = serde_json::json!({ - "plan": [{ - "step": "watch the tide", - "status": "pending", - }] - }); - let responses = mount_sse_sequence( - &server, - vec![ - sse(vec![ - ev_response_created("resp-1"), - core_test_support::responses::ev_function_call( - call_id, - "update_plan", - &serde_json::to_string(&args)?, - ), - ev_completed("resp-1"), - ]), - sse(vec![ - ev_response_created("resp-2"), - ev_assistant_message("msg-1", "plan updated"), - ev_completed("resp-2"), - ]), - ], - ) - .await; - - let reason = "blocked update plan"; - let mut builder = test_codex() - .with_pre_build_hook(|home| { - if let Err(error) = - write_pre_tool_use_hook(home, /*matcher*/ None, "json_deny", reason) - { - panic!("failed to write pre tool use hook test fixture: {error}"); - } - }) - .with_config(trust_discovered_hooks); - let test = builder.build(&server).await?; - - test.submit_turn("update the plan").await?; - - let requests = responses.requests(); - assert_eq!(requests.len(), 2); - let output_item = requests[1].function_call_output(call_id); - let output = output_item - .get("output") - .and_then(Value::as_str) - .expect("update plan output string"); - assert!( - output.contains(&format!("Tool call blocked by PreToolUse hook: {reason}")), - "blocked plan output should surface the hook reason", - ); - - let hook_inputs = read_pre_tool_use_hook_inputs(test.codex_home_path())?; - assert_eq!(hook_inputs.len(), 1); - assert_eq!(hook_inputs[0]["hook_event_name"], "PreToolUse"); - assert_eq!(hook_inputs[0]["tool_name"], "update_plan"); - assert_eq!(hook_inputs[0]["tool_use_id"], call_id); - assert_eq!(hook_inputs[0]["tool_input"], args); - - Ok(()) -} - #[tokio::test] async fn post_tool_use_records_additional_context_for_shell_command() -> Result<()> { skip_if_no_network!(Ok(())); @@ -3729,73 +3660,3 @@ async fn post_tool_use_records_apply_patch_context_with_edit_alias() -> Result<( Ok(()) } - -#[tokio::test] -async fn post_tool_use_block_decision_replaces_plan_tool_output_with_reason() -> Result<()> { - skip_if_no_network!(Ok(())); - - let server = start_mock_server().await; - let call_id = "posttooluse-update-plan"; - let args = serde_json::json!({ - "plan": [{ - "step": "watch the tide", - "status": "pending", - }] - }); - let responses = mount_sse_sequence( - &server, - vec![ - sse(vec![ - ev_response_created("resp-1"), - core_test_support::responses::ev_function_call( - call_id, - "update_plan", - &serde_json::to_string(&args)?, - ), - ev_completed("resp-1"), - ]), - sse(vec![ - ev_response_created("resp-2"), - ev_assistant_message("msg-1", "plan updated"), - ev_completed("resp-2"), - ]), - ], - ) - .await; - - let reason = "plan output blocked by post hook"; - let mut builder = test_codex() - .with_pre_build_hook(|home| { - if let Err(error) = - write_post_tool_use_hook(home, /*matcher*/ None, "decision_block", reason) - { - panic!("failed to write post tool use hook test fixture: {error}"); - } - }) - .with_config(trust_discovered_hooks); - let test = builder.build(&server).await?; - - test.submit_turn("update the plan").await?; - - let requests = responses.requests(); - assert_eq!(requests.len(), 2); - let output_item = requests[1].function_call_output(call_id); - let output = output_item - .get("output") - .and_then(Value::as_str) - .expect("update plan output string"); - assert_eq!(output, reason); - - let hook_inputs = read_post_tool_use_hook_inputs(test.codex_home_path())?; - assert_eq!(hook_inputs.len(), 1); - assert_eq!(hook_inputs[0]["hook_event_name"], "PostToolUse"); - assert_eq!(hook_inputs[0]["tool_name"], "update_plan"); - assert_eq!(hook_inputs[0]["tool_use_id"], call_id); - assert_eq!(hook_inputs[0]["tool_input"], args); - assert_eq!( - hook_inputs[0]["tool_response"], - Value::String("Plan updated".to_string()) - ); - - Ok(()) -}