Skip to content

Commit 7d58adb

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: add more fields to the GenAI client for the Agent Engine Task Store Service
PiperOrigin-RevId: 877553093
1 parent 6b5cc8f commit 7d58adb

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

tests/unit/vertexai/genai/replays/test_create_agent_engine_a2a_task.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,57 @@ def test_create_simple_a2a_task(client):
3434
a2a_task_id="task123",
3535
config=types.CreateAgentEngineTaskConfig(
3636
context_id="context123",
37+
metadata={
38+
"key": "value",
39+
"key2": [{"key3": "value3", "key4": "value4"}],
40+
},
41+
status_details=types.TaskStatusDetails(
42+
task_message=types.TaskMessage(
43+
role="user",
44+
message_id="message123",
45+
parts=[
46+
types.Part(
47+
text="hello123",
48+
)
49+
],
50+
metadata={
51+
"key42": "value42",
52+
},
53+
),
54+
),
55+
output=types.TaskOutput(
56+
artifacts=[
57+
types.TaskArtifact(
58+
artifact_id="artifact123",
59+
display_name="display_name123",
60+
description="description123",
61+
parts=[
62+
types.Part(
63+
text="hello456",
64+
)
65+
],
66+
)
67+
],
68+
),
3769
),
3870
)
3971

4072
assert isinstance(task, types.A2aTask)
4173
assert task.name == f"{agent_engine.api_resource.name}/a2aTasks/task123"
4274
assert task.context_id == "context123"
4375
assert task.state == types.State.SUBMITTED
76+
assert task.status_details.task_message.role == "user"
77+
assert task.status_details.task_message.message_id == "message123"
78+
assert task.status_details.task_message.parts[0].text == "hello123"
79+
assert task.status_details.task_message.metadata["key42"] == "value42"
80+
assert task.output.artifacts[0].artifact_id == "artifact123"
81+
assert task.output.artifacts[0].display_name == "display_name123"
82+
assert task.output.artifacts[0].description == "description123"
83+
assert task.output.artifacts[0].parts[0].text == "hello456"
84+
assert task.metadata == {
85+
"key": "value",
86+
"key2": [{"key3": "value3", "key4": "value4"}],
87+
}
4488

4589
# Clean up resources.
4690
client.agent_engines.delete(name=agent_engine.api_resource.name, force=True)

vertexai/_genai/a2a_tasks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def _CreateAgentEngineTaskConfig_to_vertex(
5151
if getv(from_object, ["context_id"]) is not None:
5252
setv(parent_object, ["contextId"], getv(from_object, ["context_id"]))
5353

54+
if getv(from_object, ["metadata"]) is not None:
55+
setv(parent_object, ["metadata"], getv(from_object, ["metadata"]))
56+
57+
if getv(from_object, ["status_details"]) is not None:
58+
setv(parent_object, ["statusDetails"], getv(from_object, ["status_details"]))
59+
60+
if getv(from_object, ["output"]) is not None:
61+
setv(parent_object, ["output"], getv(from_object, ["output"]))
62+
5463
return to_object
5564

5665

vertexai/_genai/types/common.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,15 @@ class CreateAgentEngineTaskConfig(_common.BaseModel):
13491349
context_id: Optional[str] = Field(
13501350
default=None, description="""The context id of the task to create."""
13511351
)
1352+
metadata: Optional[dict[str, Any]] = Field(
1353+
default=None, description="""The metadata of the task to create."""
1354+
)
1355+
status_details: Optional[TaskStatusDetails] = Field(
1356+
default=None, description="""The status details of the task to create."""
1357+
)
1358+
output: Optional[TaskOutput] = Field(
1359+
default=None, description="""The output of the task to create."""
1360+
)
13521361

13531362

13541363
class CreateAgentEngineTaskConfigDict(TypedDict, total=False):
@@ -1360,6 +1369,15 @@ class CreateAgentEngineTaskConfigDict(TypedDict, total=False):
13601369
context_id: Optional[str]
13611370
"""The context id of the task to create."""
13621371

1372+
metadata: Optional[dict[str, Any]]
1373+
"""The metadata of the task to create."""
1374+
1375+
status_details: Optional[TaskStatusDetailsDict]
1376+
"""The status details of the task to create."""
1377+
1378+
output: Optional[TaskOutputDict]
1379+
"""The output of the task to create."""
1380+
13631381

13641382
CreateAgentEngineTaskConfigOrDict = Union[
13651383
CreateAgentEngineTaskConfig, CreateAgentEngineTaskConfigDict

0 commit comments

Comments
 (0)