Notify: an agent's notify reaches every connected app
The notify tool now records a chat_notify app notification with its own id per call (no dedupe of repeated words) and the tool's priority, so every subscribed client gets it and a reconnecting client replays it. ntfy delivery is unchanged; the tool result names where it went. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -97,12 +97,18 @@ func (s *chatToolService) runNotify(ctx context.Context, sessionID, title, messa
|
||||
if !s.limiter.allow(sessionID, s.now()) {
|
||||
return nil, chattools.Result{Text: "Not sent: this chat already sent 5 notifications in the last minute. Wait before notifying again.", IsError: true}
|
||||
}
|
||||
delivered, detail := s.notify(ctx, sessionID, title, message)
|
||||
item := protocol.ChatShownItem{Kind: protocol.ChatShownNotify, Title: title, Message: message, Priority: priority, Delivered: delivered, Detail: detail}
|
||||
if !delivered {
|
||||
return &item, chattools.Result{Text: "Not delivered: " + detail + ".", IsError: true}
|
||||
id := newChatShownID()
|
||||
delivery := s.notify(ctx, sessionID, chatToolNotice{ID: id, Title: title, Message: message, Priority: priority})
|
||||
item := protocol.ChatShownItem{ID: id, Kind: protocol.ChatShownNotify, Title: title, Message: message, Priority: priority, Delivered: delivery.App || delivery.Phone, Detail: delivery.Detail}
|
||||
switch {
|
||||
case delivery.App && delivery.Phone:
|
||||
return &item, chattools.Result{Text: "Delivered to the operator's Pipelines apps and phone notifications."}
|
||||
case delivery.App:
|
||||
return &item, chattools.Result{Text: "Delivered to the operator's Pipelines apps; " + delivery.Detail + "."}
|
||||
case delivery.Phone:
|
||||
return &item, chattools.Result{Text: "Delivered to the operator's phone notifications."}
|
||||
}
|
||||
return &item, chattools.Result{Text: "Delivery accepted: the notification was handed to the operator's phone notification service (ntfy)."}
|
||||
return &item, chattools.Result{Text: "Not delivered: " + delivery.Detail + ".", IsError: true}
|
||||
}
|
||||
|
||||
// boundedLine folds text to one line of at most limit bytes.
|
||||
|
||||
Reference in New Issue
Block a user