File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 40
40
from fastapi .staticfiles import StaticFiles
41
41
from fastapi .websockets import WebSocket
42
42
from fastapi .websockets import WebSocketDisconnect
43
+ from google .cloud .resourcemanager_v3 import ProjectsClient
43
44
from google .genai import types
44
45
import graphviz
45
46
from opentelemetry import trace
@@ -1102,7 +1103,15 @@ async def _get_a2a_runner_async() -> Runner:
1102
1103
logger .info ("Setting up A2A agent: %s" , app_name )
1103
1104
1104
1105
try :
1105
- a2a_rpc_path = f"http://{ host } :{ port } /a2a/{ app_name } "
1106
+ if "K_SERVICE" in os .environ : # Indicating Cloud Run
1107
+ project_client = ProjectsClient ()
1108
+ project_resource_path = project_client .get_project (name = f"projects/{ os .getenv ('GOOGLE_CLOUD_PROJECT' )} " ).name
1109
+ project_number = project_resource_path .split ('/' )[- 1 ]
1110
+ cloud_run_service_url = f"{ os .getenv ('K_SERVICE' )} -{ project_number } .{ os .getenv ('GOOGLE_CLOUD_LOCATION' )} .run.app"
1111
+ a2a_rpc_path = f"https://{ cloud_run_service_url } /a2a/{ app_name } "
1112
+ logger .info ("Constructed Cloud Run URL to A2A App: %s" , a2a_rpc_path )
1113
+ else :
1114
+ a2a_rpc_path = f"http://{ host } :{ port } /a2a/{ app_name } "
1106
1115
1107
1116
agent_executor = A2aAgentExecutor (
1108
1117
runner = create_a2a_runner_loader (app_name ),
You can’t perform that action at this time.
0 commit comments