chore: Removes unused to_agent_config method in BaseAgentConfig

PiperOrigin-RevId: 797502656
This commit is contained in:
Wei Sun (Jack)
2025-08-20 16:08:05 -07:00
committed by Copybara-Service
parent 54ed079100
commit e93f861cde
2 changed files with 19 additions and 11 deletions
@@ -79,12 +79,3 @@ Example:
default=None,
description='Optional. The after_agent_callbacks of the agent.',
)
def to_agent_config(
self, custom_agent_config_cls: Type[TBaseAgentConfig]
) -> TBaseAgentConfig:
"""Converts this config to the concrete agent config type.
NOTE: this is for ADK framework use only.
"""
return custom_agent_config_cls.model_validate(self.model_dump())
+19 -2
View File
@@ -1,3 +1,17 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Literal
from google.adk.agents.agent_config import AgentConfig
@@ -115,9 +129,12 @@ other_field: other value
config = AgentConfig.model_validate(config_data)
assert isinstance(config.root, BaseAgentConfig)
# pylint: disable=unidiomatic-typecheck Needs exact class matching.
assert type(config.root) is BaseAgentConfig
assert config.root.agent_class == "mylib.agents.MyCustomAgent"
assert config.root.model_extra == {"other_field": "other value"}
my_custom_config = config.root.to_agent_config(MyCustomAgentConfig)
my_custom_config = MyCustomAgentConfig.model_validate(
config.root.model_dump()
)
assert my_custom_config.other_field == "other value"