mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 21:55:49 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
49
tests/test_skill_executor_trace.py
Normal file
49
tests/test_skill_executor_trace.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
from oclaw.openclaw_runtime.skill_executor import SkillExecutionContext, SkillExecutor
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
class _DummyStore:
|
||||
def __init__(self) -> None:
|
||||
self.events: list[dict] = []
|
||||
self.logs: list[dict] = []
|
||||
self.messages: list[dict] = []
|
||||
|
||||
def add_trace_event(self, **kwargs): # noqa: ANN003
|
||||
self.events.append(dict(kwargs))
|
||||
|
||||
def add_tool_log(self, **kwargs): # noqa: ANN003
|
||||
self.logs.append(dict(kwargs))
|
||||
|
||||
def add_message(self, **kwargs): # noqa: ANN003
|
||||
self.messages.append(dict(kwargs))
|
||||
return SimpleNamespace(id=len(self.messages))
|
||||
|
||||
|
||||
def test_skill_executor_emits_skill_trace_events() -> None:
|
||||
store = _DummyStore()
|
||||
reg = ToolRegistry(
|
||||
[
|
||||
ToolSpec(
|
||||
name="echo_skill",
|
||||
description="echo",
|
||||
parameters={"type": "object", "properties": {"x": {"type": "string"}}},
|
||||
handler=lambda a: {"ok": True, "x": a.get("x")},
|
||||
read_only=True,
|
||||
)
|
||||
]
|
||||
)
|
||||
ex = SkillExecutor()
|
||||
uses = [SimpleNamespace(id="call_1", name="echo_skill", arguments={"x": "1"})]
|
||||
ex.execute_skill_uses(
|
||||
ctx=SkillExecutionContext(store=store, tools=reg, session_id="s1", trace_id="t1"),
|
||||
assistant_msg_id=1,
|
||||
skill_uses=uses,
|
||||
)
|
||||
et = [str((e.get("event_type") or "")) for e in store.events]
|
||||
assert "skill_selected" in et
|
||||
assert "skill_executed" in et
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue