Now we have server tool and client tool
This commit is contained in:
@@ -136,6 +136,7 @@ async def test_turn_with_tool_call_then_results(monkeypatch):
|
||||
type="tool_call",
|
||||
tool_call={
|
||||
"id": "call_ok",
|
||||
"executor": "client",
|
||||
"type": "function",
|
||||
"function": {"name": "weather", "arguments": "{\"city\":\"hz\"}"},
|
||||
},
|
||||
@@ -183,6 +184,7 @@ async def test_turn_with_tool_call_timeout(monkeypatch):
|
||||
type="tool_call",
|
||||
tool_call={
|
||||
"id": "call_timeout",
|
||||
"executor": "client",
|
||||
"type": "function",
|
||||
"function": {"name": "search", "arguments": "{\"query\":\"x\"}"},
|
||||
},
|
||||
@@ -217,3 +219,36 @@ async def test_duplicate_tool_results_are_ignored(monkeypatch):
|
||||
result = await pipeline._wait_for_single_tool_result("call_dup")
|
||||
|
||||
assert result.get("output", {}).get("value") == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_server_calculator_emits_tool_result(monkeypatch):
|
||||
pipeline, events = _build_pipeline(
|
||||
monkeypatch,
|
||||
[
|
||||
[
|
||||
LLMStreamEvent(
|
||||
type="tool_call",
|
||||
tool_call={
|
||||
"id": "call_calc",
|
||||
"executor": "server",
|
||||
"type": "function",
|
||||
"function": {"name": "calculator", "arguments": "{\"expression\":\"1+2\"}"},
|
||||
},
|
||||
),
|
||||
LLMStreamEvent(type="done"),
|
||||
],
|
||||
[
|
||||
LLMStreamEvent(type="text_delta", text="done."),
|
||||
LLMStreamEvent(type="done"),
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
await pipeline._handle_turn("calc")
|
||||
|
||||
tool_results = [e for e in events if e.get("type") == "assistant.tool_result"]
|
||||
assert tool_results
|
||||
payload = tool_results[-1].get("result", {})
|
||||
assert payload.get("status", {}).get("code") == 200
|
||||
assert payload.get("output", {}).get("result") == 3
|
||||
|
||||
Reference in New Issue
Block a user