diff --git a/src/google/adk/agents/base_agent_config.py b/src/google/adk/agents/base_agent_config.py index 178587b8..57979f0e 100644 --- a/src/google/adk/agents/base_agent_config.py +++ b/src/google/adk/agents/base_agent_config.py @@ -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()) diff --git a/tests/unittests/agents/test_agent_config.py b/tests/unittests/agents/test_agent_config.py index d7c3f078..ffe190e1 100644 --- a/tests/unittests/agents/test_agent_config.py +++ b/tests/unittests/agents/test_agent_config.py @@ -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"