mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore(config): replace @working_in_progress with @experimental for config agent feature
PiperOrigin-RevId: 792803076
This commit is contained in:
committed by
Copybara-Service
parent
944e39ec2a
commit
b4f1ebea31
@@ -20,7 +20,7 @@ from typing import Union
|
||||
from pydantic import Discriminator
|
||||
from pydantic import RootModel
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent import BaseAgentConfig
|
||||
from .llm_agent_config import LlmAgentConfig
|
||||
from .loop_agent_config import LoopAgentConfig
|
||||
@@ -55,7 +55,7 @@ def agent_config_discriminator(v: Any):
|
||||
|
||||
# Use a RootModel to represent the agent directly at the top level.
|
||||
# The `discriminator` is applied to the union within the RootModel.
|
||||
@working_in_progress("AgentConfig is not ready for use.")
|
||||
@experimental
|
||||
class AgentConfig(RootModel[ConfigsUnion]):
|
||||
"""The config for the YAML schema to create an agent."""
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ from typing_extensions import override
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..events.event import Event
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
from .callback_context import CallbackContext
|
||||
from .common_configs import AgentRefConfig
|
||||
@@ -506,6 +506,7 @@ class BaseAgent(BaseModel):
|
||||
|
||||
@final
|
||||
@classmethod
|
||||
@experimental
|
||||
def from_config(
|
||||
cls: Type[SelfAgent],
|
||||
config: BaseAgentConfig,
|
||||
@@ -529,6 +530,7 @@ class BaseAgent(BaseModel):
|
||||
return cls(**kwargs)
|
||||
|
||||
@classmethod
|
||||
@experimental
|
||||
def _parse_config(
|
||||
cls: Type[SelfAgent],
|
||||
config: BaseAgentConfig,
|
||||
|
||||
@@ -14,46 +14,25 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from typing import Any
|
||||
from typing import AsyncGenerator
|
||||
from typing import Awaitable
|
||||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import final
|
||||
from typing import List
|
||||
from typing import Literal
|
||||
from typing import Mapping
|
||||
from typing import Optional
|
||||
from typing import Type
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TypeVar
|
||||
from typing import Union
|
||||
|
||||
from google.genai import types
|
||||
from opentelemetry import trace
|
||||
from pydantic import BaseModel
|
||||
from pydantic import ConfigDict
|
||||
from pydantic import Field
|
||||
from pydantic import field_validator
|
||||
from pydantic import model_validator
|
||||
from typing_extensions import override
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ..events.event import Event
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from .callback_context import CallbackContext
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .common_configs import AgentRefConfig
|
||||
from .common_configs import CodeConfig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .invocation_context import InvocationContext
|
||||
|
||||
|
||||
TBaseAgentConfig = TypeVar('TBaseAgentConfig', bound='BaseAgentConfig')
|
||||
|
||||
|
||||
@working_in_progress('BaseAgentConfig is not ready for use.')
|
||||
@experimental
|
||||
class BaseAgentConfig(BaseModel):
|
||||
"""The config for the YAML schema of a BaseAgent.
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ from pydantic import BaseModel
|
||||
from pydantic import ConfigDict
|
||||
from pydantic import model_validator
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
|
||||
|
||||
@working_in_progress("ArgumentConfig is not ready for use.")
|
||||
@experimental
|
||||
class ArgumentConfig(BaseModel):
|
||||
"""An argument passed to a function or a class's constructor."""
|
||||
|
||||
@@ -42,7 +42,7 @@ class ArgumentConfig(BaseModel):
|
||||
"""The argument value."""
|
||||
|
||||
|
||||
@working_in_progress("CodeConfig is not ready for use.")
|
||||
@experimental
|
||||
class CodeConfig(BaseModel):
|
||||
"""Code reference config for a variable, a function, or a class.
|
||||
|
||||
@@ -80,6 +80,7 @@ class CodeConfig(BaseModel):
|
||||
"""
|
||||
|
||||
|
||||
@experimental
|
||||
class AgentRefConfig(BaseModel):
|
||||
"""The config for the reference to another agent."""
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from typing import List
|
||||
|
||||
import yaml
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .agent_config import AgentConfig
|
||||
from .base_agent import BaseAgent
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
@@ -30,7 +30,7 @@ from .common_configs import AgentRefConfig
|
||||
from .common_configs import CodeConfig
|
||||
|
||||
|
||||
@working_in_progress("from_config is not ready for use.")
|
||||
@experimental
|
||||
def from_config(config_path: str) -> BaseAgent:
|
||||
"""Build agent from a configfile path.
|
||||
|
||||
@@ -79,7 +79,6 @@ def _resolve_agent_class(agent_class: str) -> type[BaseAgent]:
|
||||
)
|
||||
|
||||
|
||||
@working_in_progress("_load_config_from_path is not ready for use.")
|
||||
def _load_config_from_path(config_path: str) -> AgentConfig:
|
||||
"""Load an agent's configuration from a YAML file.
|
||||
|
||||
@@ -103,7 +102,7 @@ def _load_config_from_path(config_path: str) -> AgentConfig:
|
||||
return AgentConfig.model_validate(config_data)
|
||||
|
||||
|
||||
@working_in_progress("resolve_fully_qualified_name is not ready for use.")
|
||||
@experimental
|
||||
def resolve_fully_qualified_name(name: str) -> Any:
|
||||
try:
|
||||
module_path, obj_name = name.rsplit(".", 1)
|
||||
@@ -113,7 +112,7 @@ def resolve_fully_qualified_name(name: str) -> Any:
|
||||
raise ValueError(f"Invalid fully qualified name: {name}") from e
|
||||
|
||||
|
||||
@working_in_progress("resolve_agent_reference is not ready for use.")
|
||||
@experimental
|
||||
def resolve_agent_reference(
|
||||
ref_config: AgentRefConfig, referencing_agent_config_abs_path: str
|
||||
) -> BaseAgent:
|
||||
@@ -143,7 +142,6 @@ def resolve_agent_reference(
|
||||
raise ValueError("AgentRefConfig must have either 'code' or 'config_path'")
|
||||
|
||||
|
||||
@working_in_progress("_resolve_agent_code_reference is not ready for use.")
|
||||
def _resolve_agent_code_reference(code: str) -> Any:
|
||||
"""Resolve a code reference to an actual agent instance.
|
||||
|
||||
@@ -172,7 +170,7 @@ def _resolve_agent_code_reference(code: str) -> Any:
|
||||
return obj
|
||||
|
||||
|
||||
@working_in_progress("resolve_code_reference is not ready for use.")
|
||||
@experimental
|
||||
def resolve_code_reference(code_config: CodeConfig) -> Any:
|
||||
"""Resolve a code reference to actual Python object.
|
||||
|
||||
@@ -201,7 +199,7 @@ def resolve_code_reference(code_config: CodeConfig) -> Any:
|
||||
return obj
|
||||
|
||||
|
||||
@working_in_progress("resolve_callbacks is not ready for use.")
|
||||
@experimental
|
||||
def resolve_callbacks(callbacks_config: List[CodeConfig]) -> Any:
|
||||
"""Resolve callbacks from configuration.
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ from ..tools.base_toolset import BaseToolset
|
||||
from ..tools.function_tool import FunctionTool
|
||||
from ..tools.tool_configs import ToolConfig
|
||||
from ..tools.tool_context import ToolContext
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent import BaseAgent
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
from .callback_context import CallbackContext
|
||||
@@ -521,7 +521,7 @@ class LlmAgent(BaseAgent):
|
||||
return generate_content_config
|
||||
|
||||
@classmethod
|
||||
@working_in_progress('LlmAgent._resolve_tools is not ready for use.')
|
||||
@experimental
|
||||
def _resolve_tools(
|
||||
cls, tool_configs: list[ToolConfig], config_abs_path: str
|
||||
) -> list[Any]:
|
||||
@@ -580,6 +580,7 @@ class LlmAgent(BaseAgent):
|
||||
|
||||
@override
|
||||
@classmethod
|
||||
@experimental
|
||||
def _parse_config(
|
||||
cls: Type[LlmAgent],
|
||||
config: LlmAgentConfig,
|
||||
|
||||
@@ -27,7 +27,7 @@ from typing_extensions import override
|
||||
|
||||
from ..agents.invocation_context import InvocationContext
|
||||
from ..events.event import Event
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent import BaseAgent
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
from .loop_agent_config import LoopAgentConfig
|
||||
@@ -78,6 +78,7 @@ class LoopAgent(BaseAgent):
|
||||
|
||||
@override
|
||||
@classmethod
|
||||
@experimental
|
||||
def _parse_config(
|
||||
cls: type[LoopAgent],
|
||||
config: LoopAgentConfig,
|
||||
|
||||
@@ -21,11 +21,11 @@ from typing import Optional
|
||||
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
|
||||
|
||||
@working_in_progress('LoopAgentConfig is not ready for use.')
|
||||
@experimental
|
||||
class LoopAgentConfig(BaseAgentConfig):
|
||||
"""The config for the YAML schema of a LoopAgent."""
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ from typing import Type
|
||||
from typing_extensions import override
|
||||
|
||||
from ..events.event import Event
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from .base_agent import BaseAgent
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
from .invocation_context import InvocationContext
|
||||
|
||||
@@ -20,11 +20,11 @@ from typing import Literal
|
||||
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
from .base_agent_config import BaseAgentConfig
|
||||
|
||||
|
||||
@working_in_progress('ParallelAgentConfig is not ready for use.')
|
||||
@experimental
|
||||
class ParallelAgentConfig(BaseAgentConfig):
|
||||
"""The config for the YAML schema of a ParallelAgent."""
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ from typing import Type
|
||||
from typing_extensions import override
|
||||
|
||||
from ..events.event import Event
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from .base_agent import BaseAgent
|
||||
from .base_agent import BaseAgentConfig
|
||||
from .invocation_context import InvocationContext
|
||||
|
||||
@@ -20,11 +20,11 @@ from typing import Literal
|
||||
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from ..agents.base_agent import working_in_progress
|
||||
from ..agents.base_agent import experimental
|
||||
from ..agents.base_agent_config import BaseAgentConfig
|
||||
|
||||
|
||||
@working_in_progress('SequentialAgentConfig is not ready for use.')
|
||||
@experimental
|
||||
class SequentialAgentConfig(BaseAgentConfig):
|
||||
"""The config for the YAML schema of a SequentialAgent."""
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ from typing_extensions import override
|
||||
from . import envs
|
||||
from ...agents import config_agent_utils
|
||||
from ...agents.base_agent import BaseAgent
|
||||
from ...utils.feature_decorator import working_in_progress
|
||||
from ...utils.feature_decorator import experimental
|
||||
from .base_agent_loader import BaseAgentLoader
|
||||
|
||||
logger = logging.getLogger("google_adk." + __name__)
|
||||
@@ -138,7 +138,7 @@ class AgentLoader(BaseAgentLoader):
|
||||
|
||||
return None
|
||||
|
||||
@working_in_progress("_load_from_yaml_config is not ready for use.")
|
||||
@experimental
|
||||
def _load_from_yaml_config(self, agent_name: str) -> Optional[BaseAgent]:
|
||||
# Load from the config file at agents_dir/{agent_name}/root_agent.yaml
|
||||
config_path = os.path.join(self.agents_dir, agent_name, "root_agent.yaml")
|
||||
@@ -178,9 +178,7 @@ class AgentLoader(BaseAgentLoader):
|
||||
if root_agent := self._load_from_submodule(agent_name):
|
||||
return root_agent
|
||||
|
||||
if os.getenv("ADK_ALLOW_WIP_FEATURES") and (
|
||||
root_agent := self._load_from_yaml_config(agent_name)
|
||||
):
|
||||
if root_agent := self._load_from_yaml_config(agent_name):
|
||||
return root_agent
|
||||
|
||||
# If no root_agent was found by any pattern
|
||||
|
||||
@@ -28,7 +28,6 @@ from ..events.event import Event
|
||||
from ..models.llm_request import LlmRequest
|
||||
from ..models.llm_response import LlmResponse
|
||||
from ..tools.base_tool import BaseTool
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..agents.invocation_context import InvocationContext
|
||||
|
||||
@@ -19,10 +19,10 @@ from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from ..utils.feature_decorator import working_in_progress
|
||||
from ..utils.feature_decorator import experimental
|
||||
|
||||
|
||||
@working_in_progress("BaseToolConfig is not ready for use.")
|
||||
@experimental
|
||||
class BaseToolConfig(BaseModel):
|
||||
"""The base class for all tool configs."""
|
||||
|
||||
@@ -30,14 +30,14 @@ class BaseToolConfig(BaseModel):
|
||||
"""Forbid extra fields."""
|
||||
|
||||
|
||||
@working_in_progress("ToolArgsConfig is not ready for use.")
|
||||
@experimental
|
||||
class ToolArgsConfig(BaseModel):
|
||||
"""Config to host free key-value pairs for the args in ToolConfig."""
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
|
||||
@working_in_progress("ToolConfig is not ready for use.")
|
||||
@experimental
|
||||
class ToolConfig(BaseModel):
|
||||
"""The configuration for a tool.
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ class TestAgentLoader:
|
||||
"""Ensure sys.path is restored after each test."""
|
||||
original_path = sys.path.copy()
|
||||
original_env = os.environ.copy()
|
||||
# Enable WIP features for YAML agent loading tests
|
||||
os.environ["ADK_ALLOW_WIP_FEATURES"] = "true"
|
||||
yield
|
||||
sys.path[:] = original_path
|
||||
# Restore environment variables
|
||||
|
||||
Reference in New Issue
Block a user