From b7675a836a114e496fec40a1e9c483646219f1a7 Mon Sep 17 00:00:00 2001 From: hemasumanth Date: Fri, 17 Apr 2026 15:56:51 -0400 Subject: [PATCH] Add region support for ADK agent deployments Allow users to specify a deployment region in the agent config YAML. When set, the region is passed to the API when creating workspaces and deployments. If omitted, the backend uses its default region. Config example: region: atl1 Made-with: Cursor --- gradient_adk/cli/agent/deployment/deploy_service.py | 6 ++++++ gradient_adk/cli/cli.py | 4 +++- gradient_adk/cli/config/agent_config_manager.py | 3 +++ gradient_adk/cli/config/yaml_agent_config_manager.py | 12 ++++++++++-- gradient_adk/digital_ocean_api/models.py | 6 ++++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/gradient_adk/cli/agent/deployment/deploy_service.py b/gradient_adk/cli/agent/deployment/deploy_service.py index dec40b0..0c5ce19 100644 --- a/gradient_adk/cli/agent/deployment/deploy_service.py +++ b/gradient_adk/cli/agent/deployment/deploy_service.py @@ -44,6 +44,7 @@ async def deploy_agent( source_dir: Path, project_id: str, api_token: str, + region: str | None = None, ) -> None: """Deploy the agent to the configured environment.""" ... @@ -86,6 +87,7 @@ async def deploy_agent( project_id: str, api_token: str, description: str | None = None, + region: str | None = None, ) -> str: """Deploy an agent to the platform. @@ -139,6 +141,7 @@ async def deploy_agent( code_artifact=code_artifact, project_id=project_id, description=description, + region=region, ) # Poll for deployment completion @@ -319,6 +322,7 @@ async def _create_or_update_deployment( code_artifact: AgentDeploymentCodeArtifact, project_id: str, description: str | None = None, + region: str | None = None, ) -> str: """Create or update the deployment based on what exists. @@ -344,6 +348,7 @@ async def _create_or_update_deployment( project_id=project_id, library_version=_get_adk_version(), description=description, + region=region, ) workspace_output = await self.client.create_agent_workspace(workspace_input) @@ -371,6 +376,7 @@ async def _create_or_update_deployment( agent_deployment_code_artifact=code_artifact, library_version=_get_adk_version(), description=description, + region=region, ) deployment_output = await self.client.create_agent_workspace_deployment( deployment_input diff --git a/gradient_adk/cli/cli.py b/gradient_adk/cli/cli.py index bf7b719..ba9ba28 100644 --- a/gradient_adk/cli/cli.py +++ b/gradient_adk/cli/cli.py @@ -469,8 +469,9 @@ async def deploy(): ) raise typer.Exit(1) - # Get description from config (optional) + # Get optional config values description = _agent_config_manager.get_description() + region = _agent_config_manager.get_region() # Load .gradientignore patterns and create deploy service exclude_patterns = load_gradientignore(Path.cwd()) @@ -487,6 +488,7 @@ async def deploy(): project_id=project_id, api_token=api_token, description=description, + region=region, ) invoke_url = f"https://agents.do-ai.run/v1/{workspace_uuid}/{agent_deployment_name}/run" diff --git a/gradient_adk/cli/config/agent_config_manager.py b/gradient_adk/cli/config/agent_config_manager.py index ca1dc56..ede4314 100644 --- a/gradient_adk/cli/config/agent_config_manager.py +++ b/gradient_adk/cli/config/agent_config_manager.py @@ -20,6 +20,9 @@ def get_entrypoint_file(self) -> Optional[str]: def get_description(self) -> Optional[str]: raise NotImplementedError + def get_region(self) -> Optional[str]: + raise NotImplementedError + def configure( self, agent_name: Optional[str] = None, diff --git a/gradient_adk/cli/config/yaml_agent_config_manager.py b/gradient_adk/cli/config/yaml_agent_config_manager.py index 79bde12..8d050de 100644 --- a/gradient_adk/cli/config/yaml_agent_config_manager.py +++ b/gradient_adk/cli/config/yaml_agent_config_manager.py @@ -45,12 +45,17 @@ def get_description(self) -> Optional[str]: config = self.load_config() return config.get("description") if config else None + def get_region(self) -> Optional[str]: + config = self.load_config() + return config.get("region") if config else None + def configure( self, agent_name: Optional[str] = None, agent_environment: Optional[str] = None, entrypoint_file: Optional[str] = None, description: Optional[str] = None, + region: Optional[str] = None, interactive: bool = True, ) -> None: """Configure agent settings and save to YAML file.""" @@ -107,7 +112,7 @@ def configure( raise typer.Exit(1) self._validate_entrypoint_file(entrypoint_file) - self._save_config(agent_name, agent_environment, entrypoint_file, description) + self._save_config(agent_name, agent_environment, entrypoint_file, description, region) def _validate_name(self, name: str) -> bool: """Validate that a name only contains alphanumeric characters, hyphens, and underscores.""" @@ -178,6 +183,7 @@ def _save_config( agent_environment: str, entrypoint_file: str, description: Optional[str] = None, + region: Optional[str] = None, ) -> None: """Save configuration to YAML file.""" config = { @@ -186,10 +192,12 @@ def _save_config( "entrypoint_file": entrypoint_file, } - # Only include description if provided if description is not None: config["description"] = description + if region is not None: + config["region"] = region + try: with open(self.config_file, "w") as f: yaml.safe_dump(config, f, default_flow_style=False) diff --git a/gradient_adk/digital_ocean_api/models.py b/gradient_adk/digital_ocean_api/models.py index fa7b890..f5db4ec 100644 --- a/gradient_adk/digital_ocean_api/models.py +++ b/gradient_adk/digital_ocean_api/models.py @@ -457,6 +457,9 @@ class CreateAgentWorkspaceDeploymentInput(BaseModel): library_version: Optional[str] = Field( None, description="Version of the ADK library used to create this deployment" ) + region: Optional[str] = Field( + None, description="The region to deploy the agent in" + ) description: Optional[str] = Field( None, description="Description of the agent deployment (max 1000 characters)", @@ -543,6 +546,9 @@ class CreateAgentWorkspaceInput(BaseModel): library_version: Optional[str] = Field( None, description="Version of the ADK library used to create this workspace" ) + region: Optional[str] = Field( + None, description="The region to deploy the agent in" + ) description: Optional[str] = Field( None, description="Description of the agent workspace deployment (max 1000 characters)",