Skip to content

Commit 3cdaea7

Browse files
committed
feat(gooddata-sdk): [AUTO] Add ToolCallEventResult schema and toolCallEvents to chat response
1 parent 37d0593 commit 3cdaea7

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

packages/gooddata-sdk/src/gooddata_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
from gooddata_sdk.compute.compute_to_sdk_converter import ComputeToSdkConverter
275275
from gooddata_sdk.compute.model.attribute import Attribute
276276
from gooddata_sdk.compute.model.base import ExecModelEntity, ObjId
277+
from gooddata_sdk.compute.model.chat import ToolCallEventResult
277278
from gooddata_sdk.compute.model.execution import (
278279
BareExecutionResponse,
279280
Execution,
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# (C) 2026 GoodData Corporation
2+
from __future__ import annotations
3+
4+
import attrs
5+
from gooddata_api_client.model.tool_call_event_result import (
6+
ToolCallEventResult as ApiToolCallEventResult,
7+
)
8+
9+
from gooddata_sdk.catalog.base import Base
10+
11+
12+
@attrs.define(kw_only=True)
13+
class ToolCallEventResult(Base):
14+
"""Represents a tool call event emitted during the agentic loop.
15+
16+
Only present in :class:`~gooddata_api_client.model.chat_result.ChatResult`
17+
when the ``GEN_AI_YIELD_TOOL_CALL_EVENTS`` feature flag is enabled on the
18+
GoodData backend.
19+
"""
20+
21+
function_arguments: str
22+
"""JSON-encoded arguments passed to the tool function."""
23+
24+
function_name: str
25+
"""Name of the tool function that was called."""
26+
27+
result: str
28+
"""Result returned by the tool function."""
29+
30+
@staticmethod
31+
def client_class() -> type[ApiToolCallEventResult]:
32+
return ApiToolCallEventResult
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# (C) 2026 GoodData Corporation
2+
from __future__ import annotations
3+
4+
import pytest
5+
from gooddata_sdk.compute.model.chat import ToolCallEventResult
6+
7+
8+
@pytest.mark.parametrize(
9+
"scenario, input_data, expected_snake",
10+
[
11+
(
12+
"basic",
13+
{
14+
"functionArguments": '{"x": 1}',
15+
"functionName": "get_revenue",
16+
"result": "42",
17+
},
18+
{
19+
"function_arguments": '{"x": 1}',
20+
"function_name": "get_revenue",
21+
"result": "42",
22+
},
23+
),
24+
(
25+
"empty_strings",
26+
{
27+
"functionArguments": "",
28+
"functionName": "noop",
29+
"result": "",
30+
},
31+
{
32+
"function_arguments": "",
33+
"function_name": "noop",
34+
"result": "",
35+
},
36+
),
37+
],
38+
)
39+
def test_tool_call_event_result_from_dict(scenario, input_data, expected_snake):
40+
"""Verify ToolCallEventResult round-trips through from_dict / to_dict."""
41+
model = ToolCallEventResult.from_dict(input_data)
42+
43+
assert model.function_arguments == expected_snake["function_arguments"]
44+
assert model.function_name == expected_snake["function_name"]
45+
assert model.result == expected_snake["result"]
46+
47+
# Round-trip back to camelCase dict
48+
as_dict = model.to_dict(camel_case=True)
49+
assert as_dict["functionArguments"] == expected_snake["function_arguments"]
50+
assert as_dict["functionName"] == expected_snake["function_name"]
51+
assert as_dict["result"] == expected_snake["result"]
52+
53+
54+
def test_tool_call_event_result_construction():
55+
"""Verify direct construction and attribute access."""
56+
evt = ToolCallEventResult(
57+
function_arguments='{"threshold": 0.5}',
58+
function_name="filter_results",
59+
result="filtered",
60+
)
61+
assert evt.function_arguments == '{"threshold": 0.5}'
62+
assert evt.function_name == "filter_results"
63+
assert evt.result == "filtered"
64+
65+
66+
def test_tool_call_event_result_client_class():
67+
"""Verify client_class() returns the generated API model class."""
68+
from gooddata_api_client.model.tool_call_event_result import ToolCallEventResult as ApiToolCallEventResult
69+
70+
assert ToolCallEventResult.client_class() is ApiToolCallEventResult

0 commit comments

Comments
 (0)