mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 08:10:48 +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
39
tests/test_tool_batch_partition.py
Normal file
39
tests/test_tool_batch_partition.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.chat.tool_runtime import partition_tool_use_batches
|
||||
from oclaw.platform.llm.chat_models import LLMToolCall
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
def _spec(name: str, *, read_only: bool) -> ToolSpec:
|
||||
return ToolSpec(
|
||||
name=name,
|
||||
description="t",
|
||||
parameters={"type": "object", "properties": {}},
|
||||
handler=lambda _a: {"ok": True},
|
||||
read_only=read_only,
|
||||
)
|
||||
|
||||
|
||||
def test_partition_merges_consecutive_read_only() -> None:
|
||||
reg = ToolRegistry([_spec("a", read_only=True), _spec("b", read_only=True), _spec("c", read_only=False)])
|
||||
calls = [
|
||||
LLMToolCall(id="1", name="a", arguments={}),
|
||||
LLMToolCall(id="2", name="b", arguments={}),
|
||||
LLMToolCall(id="3", name="c", arguments={}),
|
||||
LLMToolCall(id="4", name="a", arguments={}),
|
||||
]
|
||||
batches = partition_tool_use_batches(calls, reg)
|
||||
assert [len(b) for b in batches] == [2, 1, 1]
|
||||
assert [tc.id for b in batches for tc in b] == ["1", "2", "3", "4"]
|
||||
|
||||
|
||||
def test_partition_unknown_tool_is_sequential_only() -> None:
|
||||
reg = ToolRegistry([_spec("a", read_only=True)])
|
||||
calls = [
|
||||
LLMToolCall(id="1", name="a", arguments={}),
|
||||
LLMToolCall(id="2", name="missing", arguments={}),
|
||||
LLMToolCall(id="3", name="a", arguments={}),
|
||||
]
|
||||
batches = partition_tool_use_batches(calls, reg)
|
||||
assert [len(b) for b in batches] == [1, 1, 1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue