@@ -460,6 +460,7 @@ func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, erro
460
460
rma := remoteMultiAgentHandler {
461
461
sdk : c ,
462
462
nc : nc ,
463
+ cancel : cancel ,
463
464
legacyAgentCache : map [uuid.UUID ]bool {},
464
465
}
465
466
@@ -485,6 +486,7 @@ func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, erro
485
486
err := dec .Decode (& msg )
486
487
if err != nil {
487
488
if xerrors .Is (err , io .EOF ) {
489
+ c .SDKClient .Logger ().Info (ctx , "multiagent connection severed" , slog .Error (err ))
488
490
return
489
491
}
490
492
@@ -504,8 +506,9 @@ func (c *Client) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, erro
504
506
}
505
507
506
508
type remoteMultiAgentHandler struct {
507
- sdk * Client
508
- nc net.Conn
509
+ sdk * Client
510
+ nc net.Conn
511
+ cancel func ()
509
512
510
513
legacyMu sync.RWMutex
511
514
legacyAgentCache map [uuid.UUID ]bool
@@ -522,10 +525,12 @@ func (a *remoteMultiAgentHandler) writeJSON(v interface{}) error {
522
525
// Node updates are tiny, so even the dinkiest connection can handle them if it's not hung.
523
526
err = a .nc .SetWriteDeadline (time .Now ().Add (agpl .WriteTimeout ))
524
527
if err != nil {
528
+ a .cancel ()
525
529
return xerrors .Errorf ("set write deadline: %w" , err )
526
530
}
527
531
_ , err = a .nc .Write (data )
528
532
if err != nil {
533
+ a .cancel ()
529
534
return xerrors .Errorf ("write message: %w" , err )
530
535
}
531
536
@@ -536,6 +541,7 @@ func (a *remoteMultiAgentHandler) writeJSON(v interface{}) error {
536
541
// our successful write, it is important that we reset the deadline before it fires.
537
542
err = a .nc .SetWriteDeadline (time.Time {})
538
543
if err != nil {
544
+ a .cancel ()
539
545
return xerrors .Errorf ("clear write deadline: %w" , err )
540
546
}
541
547
0 commit comments