Skip to content

Commit 953a43e

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: accept "a2a" as an agent_framework in the agent engine config types
PiperOrigin-RevId: 974373620
1 parent e14d6fe commit 953a43e

2 files changed

Lines changed: 82 additions & 12 deletions

File tree

tests/unit/agentplatform/genai/test_genai_client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# pylint: disable=protected-access,bad-continuation
1717

1818
import importlib
19+
import pydantic
1920
import pytest
2021
import warnings
2122
from unittest import mock
@@ -26,6 +27,7 @@
2627
from google.cloud.aiplatform import initializer as aiplatform_initializer
2728
import vertexai
2829
from vertexai._genai import client as vertexai_client
30+
from vertexai._genai import types as vertexai_types
2931

3032

3133
_TEST_PROJECT = "test-project"
@@ -122,3 +124,23 @@ def test_vertexai_client_deprecation_warning(self):
122124
warnings.simplefilter("error", FutureWarning)
123125
_ = vertexai.Client(project=_TEST_PROJECT, location=_TEST_LOCATION)
124126
_ = vertexai.Client(project=_TEST_PROJECT, location=_TEST_LOCATION)
127+
128+
129+
_AGENT_ENGINE_CONFIG_TYPES = [
130+
vertexai_types.AgentEngineConfig,
131+
vertexai_types.CreateAgentEngineConfig,
132+
vertexai_types.UpdateAgentEngineConfig,
133+
]
134+
135+
136+
@pytest.mark.parametrize("config_type", _AGENT_ENGINE_CONFIG_TYPES)
137+
def test_vertexai_agent_framework_accepts_a2a(config_type):
138+
# googleapis/python-aiplatform#7097: the backend and the SDK's own
139+
# _SUPPORTED_AGENT_FRAMEWORKS both accept a2a, so these types must too.
140+
assert config_type(agent_framework="a2a").agent_framework == "a2a"
141+
142+
143+
@pytest.mark.parametrize("config_type", _AGENT_ENGINE_CONFIG_TYPES)
144+
def test_vertexai_agent_framework_rejects_unknown(config_type):
145+
with pytest.raises(pydantic.ValidationError):
146+
config_type(agent_framework="not-a-framework")

vertexai/_genai/types/common.py

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8885,13 +8885,21 @@ class CreateAgentEngineConfig(_common.BaseModel):
88858885
""",
88868886
)
88878887
agent_framework: Optional[
8888-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
8888+
Literal[
8889+
"google-adk",
8890+
"langchain",
8891+
"langgraph",
8892+
"ag2",
8893+
"llama-index",
8894+
"custom",
8895+
"a2a",
8896+
]
88898897
] = Field(
88908898
default=None,
88918899
description="""The agent framework to be used for the Agent Engine.
88928900
The OSS agent framework used to develop the agent.
88938901
Currently supported values: "google-adk", "langchain", "langgraph",
8894-
"ag2", "llama-index", "custom".
8902+
"ag2", "llama-index", "custom", "a2a".
88958903
If not specified:
88968904
- If `agent` is specified, the agent framework will be auto-detected.
88978905
- If `source_packages` is specified, the agent framework will
@@ -9031,12 +9039,20 @@ class CreateAgentEngineConfigDict(TypedDict, total=False):
90319039
"""
90329040

90339041
agent_framework: Optional[
9034-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
9042+
Literal[
9043+
"google-adk",
9044+
"langchain",
9045+
"langgraph",
9046+
"ag2",
9047+
"llama-index",
9048+
"custom",
9049+
"a2a",
9050+
]
90359051
]
90369052
"""The agent framework to be used for the Agent Engine.
90379053
The OSS agent framework used to develop the agent.
90389054
Currently supported values: "google-adk", "langchain", "langgraph",
9039-
"ag2", "llama-index", "custom".
9055+
"ag2", "llama-index", "custom", "a2a".
90409056
If not specified:
90419057
- If `agent` is specified, the agent framework will be auto-detected.
90429058
- If `source_packages` is specified, the agent framework will
@@ -9552,13 +9568,21 @@ class UpdateAgentEngineConfig(_common.BaseModel):
95529568
""",
95539569
)
95549570
agent_framework: Optional[
9555-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
9571+
Literal[
9572+
"google-adk",
9573+
"langchain",
9574+
"langgraph",
9575+
"ag2",
9576+
"llama-index",
9577+
"custom",
9578+
"a2a",
9579+
]
95569580
] = Field(
95579581
default=None,
95589582
description="""The agent framework to be used for the Agent Engine.
95599583
The OSS agent framework used to develop the agent.
95609584
Currently supported values: "google-adk", "langchain", "langgraph",
9561-
"ag2", "llama-index", "custom".
9585+
"ag2", "llama-index", "custom", "a2a".
95629586
If not specified:
95639587
- If `agent` is specified, the agent framework will be auto-detected.
95649588
- If `source_packages` is specified, the agent framework will
@@ -9707,12 +9731,20 @@ class UpdateAgentEngineConfigDict(TypedDict, total=False):
97079731
"""
97089732

97099733
agent_framework: Optional[
9710-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
9734+
Literal[
9735+
"google-adk",
9736+
"langchain",
9737+
"langgraph",
9738+
"ag2",
9739+
"llama-index",
9740+
"custom",
9741+
"a2a",
9742+
]
97119743
]
97129744
"""The agent framework to be used for the Agent Engine.
97139745
The OSS agent framework used to develop the agent.
97149746
Currently supported values: "google-adk", "langchain", "langgraph",
9715-
"ag2", "llama-index", "custom".
9747+
"ag2", "llama-index", "custom", "a2a".
97169748
If not specified:
97179749
- If `agent` is specified, the agent framework will be auto-detected.
97189750
- If `source_packages` is specified, the agent framework will
@@ -20352,13 +20384,21 @@ class AgentEngineConfig(_common.BaseModel):
2035220384
""",
2035320385
)
2035420386
agent_framework: Optional[
20355-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
20387+
Literal[
20388+
"google-adk",
20389+
"langchain",
20390+
"langgraph",
20391+
"ag2",
20392+
"llama-index",
20393+
"custom",
20394+
"a2a",
20395+
]
2035620396
] = Field(
2035720397
default=None,
2035820398
description="""The agent framework to be used for the Agent Engine.
2035920399
The OSS agent framework used to develop the agent.
2036020400
Currently supported values: "google-adk", "langchain", "langgraph",
20361-
"ag2", "llama-index", "custom".
20401+
"ag2", "llama-index", "custom", "a2a".
2036220402
If not specified:
2036320403
- If `agent` is specified, the agent framework will be auto-detected.
2036420404
- If `source_packages` is specified, the agent framework will
@@ -20548,12 +20588,20 @@ class AgentEngineConfigDict(TypedDict, total=False):
2054820588
"""
2054920589

2055020590
agent_framework: Optional[
20551-
Literal["google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"]
20591+
Literal[
20592+
"google-adk",
20593+
"langchain",
20594+
"langgraph",
20595+
"ag2",
20596+
"llama-index",
20597+
"custom",
20598+
"a2a",
20599+
]
2055220600
]
2055320601
"""The agent framework to be used for the Agent Engine.
2055420602
The OSS agent framework used to develop the agent.
2055520603
Currently supported values: "google-adk", "langchain", "langgraph",
20556-
"ag2", "llama-index", "custom".
20604+
"ag2", "llama-index", "custom", "a2a".
2055720605
If not specified:
2055820606
- If `agent` is specified, the agent framework will be auto-detected.
2055920607
- If `source_packages` is specified, the agent framework will

0 commit comments

Comments
 (0)