@@ -34,7 +34,7 @@ async fn test_agent_spawn_hook_single() {
3434 let _ = tracing_subscriber:: fmt:: try_init ( ) ;
3535
3636 let mut test: TestCase = TestCase :: builder ( )
37- . test_name ( "agent spawn hook behavior" )
37+ . test_name ( "agent spawn hook behavior for single shell command and one turn " )
3838 . with_agent_config ( create_spawn_hook_single_shell_config ( ) )
3939 . with_responses (
4040 parse_response_streams ( include_str ! ( "./mock_responses/simple_two_turn.jsonl" ) )
@@ -58,7 +58,7 @@ async fn test_agent_spawn_hook_persistence() {
5858 let _ = tracing_subscriber:: fmt:: try_init ( ) ;
5959
6060 let mut test: TestCase = TestCase :: builder ( )
61- . test_name ( "agent spawn hook behavior" )
61+ . test_name ( "agent spawn hook behavior for single shell command and two turns " )
6262 . with_agent_config ( create_spawn_hook_single_shell_config ( ) )
6363 . with_responses (
6464 parse_response_streams ( include_str ! ( "./mock_responses/simple_two_turn.jsonl" ) )
@@ -79,3 +79,45 @@ async fn test_agent_spawn_hook_persistence() {
7979 assert_contains ( & first_msg, "Agent initialized" ) ;
8080 }
8181}
82+
83+ #[ tokio:: test]
84+ async fn test_user_prompt_hook_single ( ) {
85+ let _ = tracing_subscriber:: fmt:: try_init ( ) ;
86+ let hooks = HashMap :: from ( [
87+ (
88+ HookTrigger :: UserPromptSubmit ,
89+ vec ! [ HookConfig :: ShellCommand ( CommandHook {
90+ command: "echo 'submitted!'" . to_string( ) ,
91+ opts: BaseHookConfig {
92+ timeout_ms: 5000 ,
93+ max_output_size: 1024 ,
94+ cache_ttl_seconds: 0 ,
95+ matcher: None ,
96+ } ,
97+ } ) ] ,
98+ ) ,
99+ ] ) ;
100+
101+ let agent_config = AgentConfig :: V2025_08_22 ( AgentConfigV2025_08_22 {
102+ hooks,
103+ ..Default :: default ( )
104+ } ) ;
105+ let mut test: TestCase = TestCase :: builder ( )
106+ . test_name ( "user prompt submit hook behavior for single shell command and one turn" )
107+ . with_agent_config ( agent_config)
108+ . with_responses (
109+ parse_response_streams ( include_str ! ( "./mock_responses/simple_two_turn.jsonl" ) )
110+ . await
111+ . unwrap ( ) ,
112+ )
113+ . build ( )
114+ . await
115+ . unwrap ( ) ;
116+
117+ test. wait_until_agent_initializes ( Duration :: from_millis ( 100 ) ) . await ;
118+ test. send_prompt ( "hello" . to_string ( ) ) . await ;
119+ test. wait_until_agent_stop ( Duration :: from_millis ( 100 ) ) . await ;
120+ let req = test. requests ( ) . first ( ) . expect ( "should have one request" ) ;
121+ let first_msg = req. messages ( ) . first ( ) . expect ( "first message should exist" ) . text ( ) ;
122+ assert_contains ( & first_msg, "submitted!" ) ;
123+ }
0 commit comments