make autonomy proactive messaging strategy configurable

This commit is contained in:
DBT
2026-02-24 04:27:50 +00:00
parent 2db6b24de1
commit 791eb3b96c
5 changed files with 71 additions and 34 deletions

View File

@@ -60,18 +60,21 @@ type AutonomyConfig struct {
}
type AgentTextConfig struct {
NoResponseFallback string `json:"no_response_fallback"`
ThinkOnlyFallback string `json:"think_only_fallback"`
MemoryRecallKeywords []string `json:"memory_recall_keywords"`
LangUsage string `json:"lang_usage"`
LangInvalid string `json:"lang_invalid"`
LangUpdatedTemplate string `json:"lang_updated_template"`
SubagentsNone string `json:"subagents_none"`
SessionsNone string `json:"sessions_none"`
UnsupportedAction string `json:"unsupported_action"`
SystemRewriteTemplate string `json:"system_rewrite_template"`
RuntimeCompactionNote string `json:"runtime_compaction_note"`
StartupCompactionNote string `json:"startup_compaction_note"`
NoResponseFallback string `json:"no_response_fallback"`
ThinkOnlyFallback string `json:"think_only_fallback"`
MemoryRecallKeywords []string `json:"memory_recall_keywords"`
LangUsage string `json:"lang_usage"`
LangInvalid string `json:"lang_invalid"`
LangUpdatedTemplate string `json:"lang_updated_template"`
SubagentsNone string `json:"subagents_none"`
SessionsNone string `json:"sessions_none"`
UnsupportedAction string `json:"unsupported_action"`
SystemRewriteTemplate string `json:"system_rewrite_template"`
RuntimeCompactionNote string `json:"runtime_compaction_note"`
StartupCompactionNote string `json:"startup_compaction_note"`
AutonomyImportantKeywords []string `json:"autonomy_important_keywords"`
AutonomyCompletionTemplate string `json:"autonomy_completion_template"`
AutonomyBlockedTemplate string `json:"autonomy_blocked_template"`
}
type HeartbeatConfig struct {
@@ -324,9 +327,12 @@ func DefaultConfig() *Config {
SubagentsNone: "No subagents.",
SessionsNone: "No sessions.",
UnsupportedAction: "unsupported action",
SystemRewriteTemplate: "Rewrite the following internal system update in concise user-facing language:\n\n%s",
RuntimeCompactionNote: "[runtime-compaction] removed %d old messages, kept %d recent messages",
StartupCompactionNote: "[startup-compaction] removed %d old messages, kept %d recent messages",
SystemRewriteTemplate: "Rewrite the following internal system update in concise user-facing language:\n\n%s",
RuntimeCompactionNote: "[runtime-compaction] removed %d old messages, kept %d recent messages",
StartupCompactionNote: "[startup-compaction] removed %d old messages, kept %d recent messages",
AutonomyImportantKeywords: []string{"urgent", "重要", "付款", "payment", "上线", "release", "deadline", "截止"},
AutonomyCompletionTemplate: "✅ 已完成:%s\n下一步如需我继续处理后续直接回复“继续 %s”",
AutonomyBlockedTemplate: "⚠️ 任务受阻:%s\n原因%s\n建议回复“继续 %s”我会按当前状态重试。",
},
ContextCompaction: ContextCompactionConfig{
Enabled: true,

View File

@@ -138,6 +138,15 @@ func Validate(cfg *Config) []error {
errs = append(errs, fmt.Errorf("agents.defaults.texts.startup_compaction_note must contain two %%d placeholders"))
}
}
if len(texts.AutonomyImportantKeywords) == 0 {
errs = append(errs, fmt.Errorf("agents.defaults.texts.autonomy_important_keywords must contain at least one keyword"))
}
if strings.Count(strings.TrimSpace(texts.AutonomyCompletionTemplate), "%s") < 2 {
errs = append(errs, fmt.Errorf("agents.defaults.texts.autonomy_completion_template must contain two %%s placeholders"))
}
if strings.Count(strings.TrimSpace(texts.AutonomyBlockedTemplate), "%s") < 3 {
errs = append(errs, fmt.Errorf("agents.defaults.texts.autonomy_blocked_template must contain three %%s placeholders"))
}
if cfg.Agents.Defaults.ContextCompaction.Enabled {
cc := cfg.Agents.Defaults.ContextCompaction