@@ -21,6 +21,7 @@ import (
2121type acpBootstrapResponse struct {
2222 Conversation * spritzv1.SpritzConversation `json:"conversation"`
2323 EffectiveSessionID string `json:"effectiveSessionId,omitempty"`
24+ EffectiveCWD string `json:"effectiveCwd,omitempty"`
2425 BindingState string `json:"bindingState,omitempty"`
2526 Loaded bool `json:"loaded,omitempty"`
2627 Replaced bool `json:"replaced,omitempty"`
@@ -417,10 +418,16 @@ func (s *server) bootstrapACPConversationBinding(ctx context.Context, conversati
417418 return nil , err
418419 }
419420
420- return s .bootstrapACPConversationBindingWithClient (ctx , conversation , client , initResult )
421+ return s .bootstrapACPConversationBindingWithClient (ctx , conversation , spritz , client , initResult )
421422}
422423
423- func (s * server ) bootstrapACPConversationBindingWithClient (ctx context.Context , conversation * spritzv1.SpritzConversation , client * acpBootstrapInstanceClient , initResult * acpBootstrapInitializeResult ) (* acpBootstrapResponse , error ) {
424+ func (s * server ) bootstrapACPConversationBindingWithClient (
425+ ctx context.Context ,
426+ conversation * spritzv1.SpritzConversation ,
427+ spritz * spritzv1.Spritz ,
428+ client * acpBootstrapInstanceClient ,
429+ initResult * acpBootstrapInitializeResult ,
430+ ) (* acpBootstrapResponse , error ) {
424431 if ! initResult .AgentCapabilities .LoadSession {
425432 err := errors .New ("agent does not support session/load" )
426433 s .recordConversationBindingError (ctx , conversation .Namespace , conversation .Name , "" , err )
@@ -429,6 +436,7 @@ func (s *server) bootstrapACPConversationBindingWithClient(ctx context.Context,
429436
430437 agentInfo := normalizeBootstrapAgentInfo (initResult )
431438 capabilities := normalizeBootstrapCapabilities (initResult )
439+ effectiveCWD := resolveConversationEffectiveCWD (spritz , conversation )
432440 effectiveSessionID := strings .TrimSpace (conversation .Spec .SessionID )
433441 previousSessionID := ""
434442 bindingState := "active"
@@ -438,12 +446,12 @@ func (s *server) bootstrapACPConversationBindingWithClient(ctx context.Context,
438446 var err error
439447
440448 if effectiveSessionID != "" {
441- replayMessageCount , err = client .loadSession (ctx , effectiveSessionID , normalizeConversationCWD ( conversation . Spec . CWD ) )
449+ replayMessageCount , err = client .loadSession (ctx , effectiveSessionID , effectiveCWD )
442450 if err != nil {
443451 var rpcErr * acpBootstrapRPCError
444452 if errors .As (err , & rpcErr ) && rpcErr .missingSession () {
445453 previousSessionID = effectiveSessionID
446- effectiveSessionID , err = client .newSession (ctx , normalizeConversationCWD ( conversation . Spec . CWD ) )
454+ effectiveSessionID , err = client .newSession (ctx , effectiveCWD )
447455 if err != nil {
448456 s .recordConversationBindingError (ctx , conversation .Namespace , conversation .Name , previousSessionID , err )
449457 return nil , err
@@ -458,7 +466,7 @@ func (s *server) bootstrapACPConversationBindingWithClient(ctx context.Context,
458466 loaded = true
459467 }
460468 } else {
461- effectiveSessionID , err = client .newSession (ctx , normalizeConversationCWD ( conversation . Spec . CWD ) )
469+ effectiveSessionID , err = client .newSession (ctx , effectiveCWD )
462470 if err != nil {
463471 s .recordConversationBindingError (ctx , conversation .Namespace , conversation .Name , "" , err )
464472 return nil , err
@@ -473,11 +481,13 @@ func (s *server) bootstrapACPConversationBindingWithClient(ctx context.Context,
473481
474482 updatedConversation , err := s .updateConversationBinding (ctx , conversation .Namespace , conversation .Name , func (current * spritzv1.SpritzConversation ) {
475483 now := metav1 .Now ()
484+ current .Spec .CWD = normalizeConversationOverrideCWD (spritz , current .Spec .CWD )
476485 current .Spec .SessionID = effectiveSessionID
477486 current .Spec .AgentInfo = agentInfo
478487 current .Spec .Capabilities = capabilities
479488 current .Status .BoundSessionID = effectiveSessionID
480489 current .Status .BindingState = bindingState
490+ current .Status .EffectiveCWD = effectiveCWD
481491 current .Status .PreviousSessionID = previousSessionID
482492 current .Status .LastBoundAt = & now
483493 current .Status .LastReplayMessageCount = replayMessageCount
@@ -496,6 +506,7 @@ func (s *server) bootstrapACPConversationBindingWithClient(ctx context.Context,
496506 return & acpBootstrapResponse {
497507 Conversation : updatedConversation ,
498508 EffectiveSessionID : effectiveSessionID ,
509+ EffectiveCWD : effectiveCWD ,
499510 BindingState : bindingState ,
500511 Loaded : loaded ,
501512 Replaced : replaced ,
0 commit comments