Skip to content

fix: 補齊 contracts.tools 聲明以解決插件啟動錯誤#749

Open
samson1357924 wants to merge 1 commit intoCortexReach:masterfrom
samson1357924:fix/contracts-tools-declaration
Open

fix: 補齊 contracts.tools 聲明以解決插件啟動錯誤#749
samson1357924 wants to merge 1 commit intoCortexReach:masterfrom
samson1357924:fix/contracts-tools-declaration

Conversation

@samson1357924
Copy link
Copy Markdown

問題描述

啟動 OpenClaw 時出現以下錯誤:

[plugins] plugin must declare contracts.tools before registering agent tools (plugin=memory-lancedb-pro)

根本原因

插件代碼 (index.ts) 註冊了 14 個工具,但 openclaw.plugin.json 中缺少 contracts.tools 聲明。

根據 OpenClaw 安全機制,插件必須先在 manifest 中宣告工具清單,才能註冊這些工具。

修復方案

openclaw.plugin.json 中新增以下內容(插入在 "kind": "memory", 之後):

contracts.tools 聲明

"contracts": {
  "tools": [
    "memory_recall",
    "memory_store",
    "memory_forget",
    "memory_update",
    "memory_stats",
    "memory_debug",
    "memory_list",
    "memory_promote",
    "memory_archive",
    "memory_compact",
    "memory_explain_rank",
    "self_improvement_log",
    "self_improvement_extract_skill",
    "self_improvement_review"
  ]
}

toolMetadata 聲明

"toolMetadata": {
  "memory_stats": { "optional": true },
  "memory_debug": { "optional": true },
  "memory_list": { "optional": true },
  "memory_promote": { "optional": true },
  "memory_archive": { "optional": true },
  "memory_compact": { "optional": true },
  "memory_explain_rank": { "optional": true },
  "self_improvement_log": { "optional": true },
  "self_improvement_extract_skill": { "optional": true },
  "self_improvement_review": { "optional": true }
}

驗證結果

  • ✅ 修改後 OpenClaw 啟動無錯誤
  • ✅ 所有記憶工具正常運作
  • ✅ 管理工具仍受 enableManagementTools 配置控制
  • ✅ JSON 語法驗證通過

相關文檔

- 新增 contracts.tools 宣告所有 14 個工具
- 新增 toolMetadata 將管理工具標記為 optional: true
- 修復啟動錯誤:'plugin must declare contracts.tools before registering agent tools'
- 參考:OpenClaw Plugin Building Guide
@samson1357924
Copy link
Copy Markdown
Author

@CortexReach 您好! 👋

這是一個修復插件啟動錯誤的 PR。

問題描述
啟動 OpenClaw 時出現錯誤:

修復內容

  • 新增了 contracts.tools 宣告所有 14 個工具
  • 新增了 toolMetadata 將管理工具標記為 optional: true

驗證結果
✅ 已在本地環境驗證,啟動無錯誤且功能正常

希望這個修復能幫助改善插件!如果有任何需要修改或調整的地方,非常歡迎隨時告訴我。

感謝您開發這麼棒的記憶體插件!🙏

@jlin53882
Copy link
Copy Markdown
Contributor

@samson1357924 This PR has been replaced by PR #742 , and the content is cleaner, so it is recommended to close this PR.

@jlin53882
Copy link
Copy Markdown
Contributor

@rwmjhb It is recommended to close this PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants