Skip to content

Commit a216d95

Browse files
google-genai-botcopybara-github
authored andcommitted
feat(interactions)!: support multimodal content in CodeExecutionResultStep.result
`CodeExecutionResultStep.result` can now hold either a string or a list of Content items (e.g. text and images produced by code execution). BREAKING CHANGE: In the typed SDKs, `CodeExecutionResultStep.result` changes from `string` to the `CodeExecutionResultStepResult` union. Code that reads `result` as a string must now check which variant is present and read the string from it. The JSON for text-only results is unchanged. PiperOrigin-RevId: 1014399252
1 parent 5647e1e commit a216d95

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎google/genai/_gaos/types/interactions/__init__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
from .codeexecutionresultstep import (
6363
CodeExecutionResultStep,
6464
CodeExecutionResultStepParam,
65+
CodeExecutionResultStepResult,
66+
CodeExecutionResultStepResultParam,
6567
)
6668
from .codemenderagentconfig import CodeMenderAgentConfig, CodeMenderAgentConfigParam
6769
from .computeruse import (
@@ -481,6 +483,8 @@
481483
"CodeExecutionResultDeltaTypedDict",
482484
"CodeExecutionResultStep",
483485
"CodeExecutionResultStepParam",
486+
"CodeExecutionResultStepResult",
487+
"CodeExecutionResultStepResultParam",
484488
"CodeMenderAgentConfig",
485489
"CodeMenderAgentConfigParam",
486490
"ComputerUse",
@@ -892,6 +896,8 @@
892896
"CodeExecutionResultDeltaTypedDict": ".codeexecutionresultdelta",
893897
"CodeExecutionResultStep": ".codeexecutionresultstep",
894898
"CodeExecutionResultStepParam": ".codeexecutionresultstep",
899+
"CodeExecutionResultStepResult": ".codeexecutionresultstep",
900+
"CodeExecutionResultStepResultParam": ".codeexecutionresultstep",
895901
"CodeMenderAgentConfig": ".codemenderagentconfig",
896902
"CodeMenderAgentConfigParam": ".codemenderagentconfig",
897903
"ComputerUse": ".computeruse",

‎google/genai/_gaos/types/interactions/codeexecutionresultstep.py‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,33 @@
3232
current_filtered_dump,
3333
current_serialization_methods_dump,
3434
)
35+
from .content import Content, ContentParam
3536
import pydantic
3637
from pydantic import model_serializer
3738
from pydantic.functional_validators import AfterValidator
38-
from typing import Any, Literal, Optional, Union
39-
from typing_extensions import Annotated, NotRequired, TypedDict
39+
from typing import Any, List, Literal, Optional, Union
40+
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
41+
42+
43+
CodeExecutionResultStepResultParam = TypeAliasType(
44+
"CodeExecutionResultStepResultParam", Union[List[ContentParam], str]
45+
)
46+
r"""The output of the code execution."""
47+
48+
49+
CodeExecutionResultStepResult = TypeAliasType(
50+
"CodeExecutionResultStepResult", Union[List[Content], str]
51+
)
52+
r"""The output of the code execution."""
4053

4154

4255
class CodeExecutionResultStepParam(TypedDict):
4356
r"""Code execution result step."""
4457

4558
call_id: str
4659
r"""Required. ID to match the ID from the function call block."""
47-
result: str
48-
r"""Required. The output of the code execution."""
60+
result: CodeExecutionResultStepResultParam
61+
r"""The output of the code execution."""
4962
is_error: NotRequired[bool]
5063
r"""Whether the code execution resulted in an error."""
5164
signature: NotRequired[Union[str, Base64FileInput]]
@@ -59,8 +72,8 @@ class CodeExecutionResultStep(BaseModel):
5972
call_id: str
6073
r"""Required. ID to match the ID from the function call block."""
6174

62-
result: str
63-
r"""Required. The output of the code execution."""
75+
result: CodeExecutionResultStepResult
76+
r"""The output of the code execution."""
6477

6578
is_error: Optional[bool] = None
6679
r"""Whether the code execution resulted in an error."""

0 commit comments

Comments
 (0)