Tencent/WeKnora · error

no memory service

Error message

no memory service

What it means

SearchMemoryTool.Execute returns "no memory service" when the tool's memoryService dependency is nil, meaning long-term memory is not wired up. The tool returns ToolResult Success=false with Error="long-term memory is not available" plus this error. It is a dependency-injection guard: the tool exists but its backing store was never configured.

Source

Thrown at internal/agent/tools/search_memory.go:108

	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)

	// "Switched off" and "nothing stored matches" have to reach the model as
	// different answers. Reporting an empty store to someone who turned memory
	// off would have the agent tell them it knows nothing about them, which is
	// both wrong and the opposite of what disabling memory was meant to do.
	if !result.Available {
		return &types.ToolResult{

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Initialize and pass a valid memory service when constructing SearchMemoryTool.
  2. Unregister or skip registering the search-memory tool when long-term memory is disabled.
  3. Verify memory backend configuration/connection at startup before the agent runs.

Example fix

// before
tool := tools.NewSearchMemoryTool(nil) // nil memoryService
// after
memSvc, err := memory.NewService(cfg.Memory)
if err != nil {
    return fmt.Errorf("init memory service: %w", err)
}
tool := tools.NewSearchMemoryTool(memSvc)
Defensive patterns

Strategy: type-guard

Validate before calling

if memSvc == nil {
    return errors.New("cannot register search-memory tool: memory service not configured")
}

Type guard

func memoryAvailable(t *tools.SearchMemoryTool, svc memory.Service) bool { return svc != nil }

Try / catch

res, err := tool.Execute(ctx, input)
if err != nil && strings.Contains(err.Error(), "no memory service") {
    // degrade gracefully: skip memory search or answer without recall
}

Prevention

When it happens

Trigger: Executing SearchMemoryTool after constructing it without a memory service (New... called with nil), or in a build/configuration where long-term memory is disabled but the tool is still registered with the agent.

Common situations: Memory backend (e.g. vector store) not initialized at startup; feature flag disabling long-term memory while tools are registered unconditionally; constructor dependency accidentally passed as nil; config missing memory connection settings.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/3b18feffc3bc86a9. Report an issue: GitHub.