mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
修复 memory wiki 工具加载异常并在系统提示词声明默认 wiki 路径。
为动态加载的 memory-wiki 模块补充 sys.modules 注册以避免 dataclass 导入期崩溃,同时在统一技能策略中明确默认根路径为 data/wiki,并新增工具加载回归测试。 Made-with: Cursor
This commit is contained in:
parent
c6a1da1980
commit
27b8698f9b
3 changed files with 42 additions and 0 deletions
37
tests/test_memory_wiki_tools_loader.py
Normal file
37
tests/test_memory_wiki_tools_loader.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.runtime.tools.experts.memory.wiki_tools import (
|
||||
memory_wiki_apply_tool,
|
||||
memory_wiki_get_tool,
|
||||
memory_wiki_lint_tool,
|
||||
memory_wiki_search_tool,
|
||||
memory_wiki_status_tool,
|
||||
)
|
||||
|
||||
|
||||
def test_memory_wiki_tools_handlers_load_without_dataclass_module_error() -> None:
|
||||
status = memory_wiki_status_tool().handler({})
|
||||
assert isinstance(status, dict)
|
||||
assert "AttributeError" not in str(status.get("error", ""))
|
||||
assert "__dict__" not in str(status.get("error", ""))
|
||||
|
||||
search = memory_wiki_search_tool().handler({"query": "test"})
|
||||
assert isinstance(search, dict)
|
||||
assert "AttributeError" not in str(search.get("error", ""))
|
||||
assert "__dict__" not in str(search.get("error", ""))
|
||||
|
||||
get_res = memory_wiki_get_tool().handler({"path": "improvement/learnings.md"})
|
||||
assert isinstance(get_res, dict)
|
||||
assert "AttributeError" not in str(get_res.get("error", ""))
|
||||
assert "__dict__" not in str(get_res.get("error", ""))
|
||||
|
||||
lint = memory_wiki_lint_tool().handler({})
|
||||
assert isinstance(lint, dict)
|
||||
assert "AttributeError" not in str(lint.get("error", ""))
|
||||
assert "__dict__" not in str(lint.get("error", ""))
|
||||
|
||||
apply_res = memory_wiki_apply_tool().handler({"action": "delete", "path": "improvement/_nonexistent_test_.md"})
|
||||
assert isinstance(apply_res, dict)
|
||||
assert "AttributeError" not in str(apply_res.get("error", ""))
|
||||
assert "__dict__" not in str(apply_res.get("error", ""))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue