Skip to content

Instantly share code, notes, and snippets.

@sing1ee
Created March 1, 2026 13:29
Show Gist options
  • Select an option

  • Save sing1ee/10541f0adc90243f7e9e608a7ebff9eb to your computer and use it in GitHub Desktop.

Select an option

Save sing1ee/10541f0adc90243f7e9e608a7ebff9eb to your computer and use it in GitHub Desktop.

推荐完整配置

agents: {
  defaults: {
    memorySearch: {
      enabled: true,
      provider: "gemini",
      model: "gemini-embedding-001",
      remote: {
        apiKey: "YOUR_REAL_GEMINI_API_KEY"  // 替换为真实 key
      },
      sync: {
        watch: true,
        watchDebounceMs: 1500
      },
      query: {
        maxResults: 8,
        hybrid: {
          enabled: true,
          vectorWeight: 0.7,
          textWeight: 0.3,
          candidateMultiplier: 4,
          mmr: {
            enabled: true,
            lambda: 0.7
          },
          temporalDecay: {
            enabled: true,
            halfLifeDays: 30
          }
        }
      },
      cache: {
        enabled: true,
        maxEntries: 50000
      }
    }
  }
}

简化版(推荐新手)

如果你刚接触 memorySearch,可以使用更简单的配置,让 OpenClaw 自动选择 provider:

agents: {
  defaults: {
    memorySearch: {
      enabled: true,
      sync: {
        watch: true
      }
    }
  }
}

OpenClaw 会按以下顺序自动选择 provider:

  1. local (如果有本地模型)
  2. openai (如果有 OpenAI key)
  3. gemini (如果有 Gemini key)
  4. voyage (如果有 Voyage key)
  5. mistral (如果有 Mistral key)

注意事项

  1. API Key 环境变量:也可以不写死 API Key,而使用环境变量:

    • Gemini: GEMINI_API_KEYmodels.providers.google.apiKey
    • 其他 provider 同理
  2. Hybrid 搜索candidateMultiplier 建议设为 4(默认值),可以让结果更全面

  3. 缓存:启用缓存可以加速重复查询,建议保持开启

相关文档:https://docs.openclaw.ai/concepts/memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment