Tencent/WeKnora · error
missing query
Error message
missing query
What it means
SearchMemoryTool.Execute returns "missing query" when the tool input's Query field is empty or whitespace-only after TrimSpace. The library requires a non-empty search string to run a long-term-memory lookup, and it also returns a ToolResult with Success=false and Error="query is required" alongside this Go error. It is a guard against issuing meaningless empty memory searches.
Source
Thrown at internal/agent/tools/search_memory.go:102
}
// Execute searches the user's own long-term memory.
func (t *SearchMemoryTool) Execute(
ctx context.Context, args json.RawMessage,
) (*types.ToolResult, error) {
var input SearchMemoryInput
if err := json.Unmarshal(args, &input); err != nil {
return &types.ToolResult{
Success: false,
Error: fmt.Sprintf("Failed to parse args: %v", err),
}, err
}
query := strings.TrimSpace(input.Query)
if query == "" {
return &types.ToolResult{
Success: false,
Error: "query is required",
}, fmt.Errorf("missing query")
}
if t.memoryService == nil {
return &types.ToolResult{
Success: false,
Error: "long-term memory is not available",
}, fmt.Errorf("no memory service")
}
limit := input.Limit
if limit <= 0 {
limit = types.MemorySearchDefaultItems
}
if limit > types.MemorySearchMaxItems {
limit = types.MemorySearchMaxItems
}
result := t.memoryService.SearchMemory(ctx, query, limit)
View on GitHub (pinned to 988cbb0330)
Solutions
- Set a non-empty Query string on the tool input before calling Execute.
- Trim and validate the query in your own code before invoking the tool.
- If the query originates from model output, re-prompt or fall back when the argument is blank.
Example fix
// before
res, err := tool.Execute(ctx, types.ToolInput{Query: ""})
// after
q := strings.TrimSpace(modelArg)
if q == "" {
return errors.New("search_memory requires a non-empty query")
}
res, err := tool.Execute(ctx, types.ToolInput{Query: q}) Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(input.Query) == "" {
return errors.New("search_memory requires a non-empty query")
} Type guard
func hasQuery(input types.ToolInput) bool { return strings.TrimSpace(input.Query) != "" } Try / catch
res, err := tool.Execute(ctx, input)
if err != nil && strings.Contains(err.Error(), "missing query") {
// prompt for or default a query before retrying
} Prevention
- Always trim and check the query before tool invocation
- Set tool schemas so the query argument is required for the model
- Add a fallback default query for blank model output
When it happens
Trigger: Calling Execute on SearchMemoryTool with input.Query == "" or containing only whitespace (e.g. spaces/tabs/newlines), typically because the model emitted an empty query argument or the caller built ToolInput without setting Query.
Common situations: LLM providers emit an empty tool argument; code paths that construct the tool input programmatically forget to populate Query; templates or prompts that leave the query blank; deserialized JSON where the query key is missing.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- memory limit cannot be negative
- invalid thought: must be a non-empty string
- invalid thoughtNumber: must be >= 1
- invalid totalThoughts: must be >= 1
- invite code has expired
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/76d08552a61ea530.
Report an issue: GitHub.