autonomy notify routing: use enabled channel allow_from instead of notify_allow_chats

This commit is contained in:
DBT
2026-02-28 13:16:08 +00:00
parent c7a6d34188
commit abe002ae51
5 changed files with 23 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ type Options struct {
Workspace string
DefaultNotifyChannel string
DefaultNotifyChatID string
NotifyAllowChats []string
NotifyAllowFrom []string
NotifyCooldownSec int
NotifySameReasonCooldownSec int
QuietHours string
@@ -643,9 +643,9 @@ func (e *Engine) shouldNotify(key string, reason string) bool {
if strings.TrimSpace(e.opts.DefaultNotifyChannel) == "" || strings.TrimSpace(e.opts.DefaultNotifyChatID) == "" {
return false
}
if len(e.opts.NotifyAllowChats) > 0 {
if len(e.opts.NotifyAllowFrom) > 0 {
allowed := false
for _, c := range e.opts.NotifyAllowChats {
for _, c := range e.opts.NotifyAllowFrom {
if c == e.opts.DefaultNotifyChatID {
allowed = true
break

View File

@@ -2,11 +2,11 @@ package autonomy
import "testing"
func TestShouldNotify_RespectsNotifyAllowChats(t *testing.T) {
func TestShouldNotify_RespectsNotifyAllowFrom(t *testing.T) {
e := &Engine{opts: Options{
DefaultNotifyChannel: "telegram",
DefaultNotifyChatID: "chat-1",
NotifyAllowChats: []string{"chat-2", "chat-3"},
NotifyAllowFrom: []string{"chat-2", "chat-3"},
NotifyCooldownSec: 1,
NotifySameReasonCooldownSec: 1,
}}
@@ -14,7 +14,7 @@ func TestShouldNotify_RespectsNotifyAllowChats(t *testing.T) {
t.Fatalf("expected notify to be blocked when chat not in allowlist")
}
e.opts.NotifyAllowChats = []string{"chat-1"}
e.opts.NotifyAllowFrom = []string{"chat-1"}
if !e.shouldNotify("k2", "") {
t.Fatalf("expected notify to pass when chat in allowlist")
}

View File

@@ -61,7 +61,6 @@ type AutonomyConfig struct {
AllowedTaskKeywords []string `json:"allowed_task_keywords" env:"CLAWGO_AGENTS_DEFAULTS_AUTONOMY_ALLOWED_TASK_KEYWORDS"`
NotifyChannel string `json:"notify_channel" env:"CLAWGO_AGENTS_DEFAULTS_AUTONOMY_NOTIFY_CHANNEL"`
NotifyChatID string `json:"notify_chat_id" env:"CLAWGO_AGENTS_DEFAULTS_AUTONOMY_NOTIFY_CHAT_ID"`
NotifyAllowChats []string `json:"notify_allow_chats" env:"CLAWGO_AGENTS_DEFAULTS_AUTONOMY_NOTIFY_ALLOW_CHATS"`
}
type AgentTextConfig struct {
@@ -333,7 +332,6 @@ func DefaultConfig() *Config {
AllowedTaskKeywords: []string{},
NotifyChannel: "",
NotifyChatID: "",
NotifyAllowChats: []string{},
},
Texts: AgentTextConfig{
NoResponseFallback: "I've completed processing but have no response to give.",