@@ -5,7 +5,9 @@ use agent_client_protocol::{
55 SessionMessage , TransportBatch , TransportFrame ,
66 schema:: v1:: {
77 ContentBlock , ContentChunk , NewSessionRequest , NewSessionResponse , PromptRequest ,
8- PromptResponse , SessionId , SessionNotification , SessionUpdate , StopReason , TextContent ,
8+ PromptResponse , SessionConfigOption , SessionConfigOptionCategory ,
9+ SessionConfigSelectOption , SessionId , SessionNotification , SessionUpdate , StopReason ,
10+ TextContent ,
911 } ,
1012} ;
1113use futures:: { StreamExt as _, channel:: oneshot} ;
@@ -169,6 +171,53 @@ mod callback_future_lifetimes {
169171 }
170172}
171173
174+ #[ tokio:: test( flavor = "current_thread" ) ]
175+ async fn active_session_preserves_config_options_from_new_session_response ( ) {
176+ let config_options = vec ! [
177+ SessionConfigOption :: select(
178+ "model" ,
179+ "Model" ,
180+ "sonnet" ,
181+ vec![
182+ SessionConfigSelectOption :: new( "sonnet" , "Sonnet" ) ,
183+ SessionConfigSelectOption :: new( "opus" , "Opus" ) ,
184+ ] ,
185+ )
186+ . category( SessionConfigOptionCategory :: Model ) ,
187+ ] ;
188+ let expected_response =
189+ NewSessionResponse :: new ( "config-options-session" ) . config_options ( config_options. clone ( ) ) ;
190+ let agent_response = expected_response. clone ( ) ;
191+
192+ let agent = Agent . builder ( ) . on_receive_request (
193+ async move |_request : NewSessionRequest ,
194+ responder : Responder < NewSessionResponse > ,
195+ _connection : ConnectionTo < Client > | {
196+ responder. respond ( agent_response. clone ( ) )
197+ } ,
198+ agent_client_protocol:: on_receive_request!( ) ,
199+ ) ;
200+
201+ let client = Client
202+ . builder ( )
203+ . connect_with ( agent, async move |connection| {
204+ let session = connection
205+ . build_session_cwd ( ) ?
206+ . block_task ( )
207+ . start_session ( )
208+ . await ?;
209+
210+ assert_eq ! ( session. config_options( ) , Some ( config_options. as_slice( ) ) ) ;
211+ assert_eq ! ( session. response( ) , expected_response) ;
212+ Ok ( ( ) )
213+ } ) ;
214+
215+ tokio:: time:: timeout ( TIMEOUT , client)
216+ . await
217+ . expect ( "session setup timed out" )
218+ . expect ( "session connection failed" ) ;
219+ }
220+
172221#[ tokio:: test( flavor = "current_thread" ) ]
173222async fn on_session_start_callback_can_consume_later_session_messages ( ) {
174223 let session_id = SessionId :: new ( "ordered-session" ) ;
0 commit comments