Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

refactor(prompt): streamline context handling in templates

wizardchen1416217a0a12
diff --git a/config/prompt_templates/context_template.yaml b/config/prompt_templates/context_template.yaml
index ff5bea17c..e43b09203 100644
--- a/config/prompt_templates/context_template.yaml
+++ b/config/prompt_templates/context_template.yaml
@@ -16,16 +16,8 @@ templates:
default: true
has_knowledge_base: true
content: |
- The following is retrieved information that may or may not be relevant:
- {{contexts}}
-
User question: {{query}}
- Instructions:
- - If the retrieved information is relevant to the user's question, use it to provide an accurate answer.
- - If the retrieved information is NOT relevant (e.g., the user is greeting, chatting, or asking something unrelated), ignore it and respond naturally as a helpful assistant.
- - Do not mention "retrieved information" or "reference materials" in your response unless the user explicitly asks about sources.
-
- id: "detailed_context"
name: "Detailed Template"
description: "Context template with detailed instructions"
diff --git a/config/prompt_templates/system_prompt.yaml b/config/prompt_templates/system_prompt.yaml
index a777d8746..6fccbdd7c 100644
--- a/config/prompt_templates/system_prompt.yaml
+++ b/config/prompt_templates/system_prompt.yaml
@@ -34,6 +34,9 @@ templates:
## CRITICAL: Language Rule
- ALWAYS respond in {{language}}
+ The following is retrieved information that may or may not be relevant:
+ {{contexts}}
+
- id: "expert_assistant"
name: "Domain Expert"
description: "Expert template for in-depth domain-specific answers"
diff --git a/internal/agent/tools/param_cast.go b/internal/agent/tools/param_cast.go
index f3da8afde..9b0cf4a96 100644
--- a/internal/agent/tools/param_cast.go
+++ b/internal/agent/tools/param_cast.go
@@ -68,6 +68,12 @@ func CastParams(args json.RawMessage, schema json.RawMessage) json.RawMessage {
// Returns (newValue, true) if a conversion was made, (val, false) otherwise.
func castValue(val interface{}, targetType string) (interface{}, bool) {
switch targetType {
+ case "array":
+ // Allow a single string to satisfy string-array parameters used by tools.
+ if s, ok := val.(string); ok {
+ return []string{s}, true
+ }
+
case "boolean":
if s, ok := val.(string); ok {
lower := strings.ToLower(s)
diff --git a/internal/agent/tools/param_cast_test.go b/internal/agent/tools/param_cast_test.go
index 36d282514..611187bad 100644
--- a/internal/agent/tools/param_cast_test.go
+++ b/internal/agent/tools/param_cast_test.go
@@ -79,3 +79,22 @@ func TestCastParams_BoolFalseString(t *testing.T) {
t.Errorf("expected false, got %v (%T)", parsed["flag"], parsed["flag"])
}
}
+
+func TestCastParams_StringToStringArray(t *testing.T) {
+ schema := json.RawMessage(`{"type":"object","properties":{"patterns":{"type":"array","items":{"type":"string"}}}}`)
+ args := json.RawMessage(`{"patterns":"OpenClaw"}`)
+ result := CastParams(args, schema)
+
+ var parsed map[string]interface{}
+ if err := json.Unmarshal(result, &parsed); err != nil {
+ t.Fatal(err)
+ }
+
+ patterns, ok := parsed["patterns"].([]interface{})
+ if !ok {
+ t.Fatalf("expected patterns to be array, got %T", parsed["patterns"])
+ }
+ if len(patterns) != 1 || patterns[0] != "OpenClaw" {
+ t.Fatalf("expected [OpenClaw], got %v", patterns)
+ }
+}
diff --git a/internal/agent/tools/sequentialthinking.go b/internal/agent/tools/sequentialthinking.go
index be4c7289f..100d42b7e 100644
--- a/internal/agent/tools/sequentialthinking.go
+++ b/internal/agent/tools/sequentialthinking.go
@@ -99,7 +99,7 @@ Each thought can build on, question, or revise previous insights as understandin
"total_thoughts": {
"type": "integer",
"description": "Estimated total thoughts needed (numeric value, e.g., 5, 10)",
- "minimum": 5
+ "minimum": 1
},
"is_revision": {
"type": "boolean",