mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 18:07:36 +08:00
optimize config validation and document new text template settings
This commit is contained in:
11
README.md
11
README.md
@@ -156,7 +156,16 @@ clawgo channel test --channel telegram --to <chat_id> -m "ping"
|
||||
"texts": {
|
||||
"no_response_fallback": "I've completed processing but have no response to give.",
|
||||
"think_only_fallback": "Thinking process completed.",
|
||||
"memory_recall_keywords": ["remember", "记得", "上次", "之前", "偏好", "preference", "todo", "待办", "决定", "decision"]
|
||||
"memory_recall_keywords": ["remember", "记得", "上次", "之前", "偏好", "preference", "todo", "待办", "决定", "decision"],
|
||||
"lang_usage": "Usage: /lang <code>",
|
||||
"lang_invalid": "Invalid language code.",
|
||||
"lang_updated_template": "Language preference updated to %s",
|
||||
"subagents_none": "No subagents.",
|
||||
"sessions_none": "No sessions.",
|
||||
"unsupported_action": "unsupported action",
|
||||
"system_rewrite_template": "Rewrite the following internal system update in concise user-facing language:\n\n%s",
|
||||
"runtime_compaction_note": "[runtime-compaction] removed %d old messages, kept %d recent messages",
|
||||
"startup_compaction_note": "[startup-compaction] removed %d old messages, kept %d recent messages"
|
||||
},
|
||||
"context_compaction": {
|
||||
"enabled": true,
|
||||
|
||||
11
README_EN.md
11
README_EN.md
@@ -156,7 +156,16 @@ Heartbeat + context compaction config example:
|
||||
"texts": {
|
||||
"no_response_fallback": "I've completed processing but have no response to give.",
|
||||
"think_only_fallback": "Thinking process completed.",
|
||||
"memory_recall_keywords": ["remember", "记得", "上次", "之前", "偏好", "preference", "todo", "待办", "决定", "decision"]
|
||||
"memory_recall_keywords": ["remember", "记得", "上次", "之前", "偏好", "preference", "todo", "待办", "决定", "decision"],
|
||||
"lang_usage": "Usage: /lang <code>",
|
||||
"lang_invalid": "Invalid language code.",
|
||||
"lang_updated_template": "Language preference updated to %s",
|
||||
"subagents_none": "No subagents.",
|
||||
"sessions_none": "No sessions.",
|
||||
"unsupported_action": "unsupported action",
|
||||
"system_rewrite_template": "Rewrite the following internal system update in concise user-facing language:\n\n%s",
|
||||
"runtime_compaction_note": "[runtime-compaction] removed %d old messages, kept %d recent messages",
|
||||
"startup_compaction_note": "[startup-compaction] removed %d old messages, kept %d recent messages"
|
||||
},
|
||||
"context_compaction": {
|
||||
"enabled": true,
|
||||
|
||||
@@ -73,6 +73,39 @@ func Validate(cfg *Config) []error {
|
||||
if strings.TrimSpace(rc.SystemSummary.OutcomesTitle) == "" {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.runtime_control.system_summary.outcomes_title must be non-empty"))
|
||||
}
|
||||
hb := cfg.Agents.Defaults.Heartbeat
|
||||
if hb.Enabled {
|
||||
if hb.EverySec <= 0 {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.heartbeat.every_sec must be > 0 when enabled=true"))
|
||||
}
|
||||
if hb.AckMaxChars <= 0 {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.heartbeat.ack_max_chars must be > 0 when enabled=true"))
|
||||
}
|
||||
}
|
||||
texts := cfg.Agents.Defaults.Texts
|
||||
if strings.TrimSpace(texts.NoResponseFallback) == "" {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.no_response_fallback must be non-empty"))
|
||||
}
|
||||
if strings.TrimSpace(texts.ThinkOnlyFallback) == "" {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.think_only_fallback must be non-empty"))
|
||||
}
|
||||
if len(texts.MemoryRecallKeywords) == 0 {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.memory_recall_keywords must contain at least one keyword"))
|
||||
}
|
||||
if strings.TrimSpace(texts.LangUpdatedTemplate) != "" && !strings.Contains(texts.LangUpdatedTemplate, "%s") {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.lang_updated_template must contain %%s placeholder"))
|
||||
}
|
||||
if strings.TrimSpace(texts.RuntimeCompactionNote) != "" {
|
||||
if strings.Count(texts.RuntimeCompactionNote, "%d") < 2 {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.runtime_compaction_note must contain two %%d placeholders"))
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(texts.StartupCompactionNote) != "" {
|
||||
if strings.Count(texts.StartupCompactionNote, "%d") < 2 {
|
||||
errs = append(errs, fmt.Errorf("agents.defaults.texts.startup_compaction_note must contain two %%d placeholders"))
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.Agents.Defaults.ContextCompaction.Enabled {
|
||||
cc := cfg.Agents.Defaults.ContextCompaction
|
||||
if cc.Mode != "" {
|
||||
|
||||
Reference in New Issue
Block a user