MCPcopy Create free account
hub / github.com/google/adk-python / run_async

Method run_async

src/google/adk/tools/agent_tool.py:205–308  ·  view source on GitHub ↗
(
      self,
      *,
      args: dict[str, Any],
      tool_context: ToolContext,
  )

Source from the content-addressed store, hash-verified

203
204 @override
205 async def run_async(
206 self,
207 *,
208 args: dict[str, Any],
209 tool_context: ToolContext,
210 ) -> Any:
211 from ..runners import Runner
212 from ..sessions.in_memory_session_service import InMemorySessionService
213
214 if self.skip_summarization:
215 tool_context.actions.skip_summarization = True
216
217 input_schema = _get_input_schema(self.agent)
218 if input_schema:
219 input_value = input_schema.model_validate(args)
220 content = types.Content(
221 role='user',
222 parts=[
223 types.Part.from_text(
224 text=input_value.model_dump_json(exclude_none=True)
225 )
226 ],
227 )
228 else:
229 if 'request' in args:
230 request_text = args['request']
231 else:
232 request_text = json.dumps(args, ensure_ascii=False, sort_keys=True)
233 content = types.Content(
234 role='user',
235 parts=[types.Part.from_text(text=request_text)],
236 )
237 invocation_context = tool_context._invocation_context
238 parent_app_name = (
239 invocation_context.app_name if invocation_context else None
240 )
241 child_app_name = parent_app_name or self.agent.name
242 plugins = (
243 tool_context._invocation_context.plugin_manager.plugins
244 if self.include_plugins
245 else None
246 )
247 runner = Runner(
248 app_name=child_app_name,
249 agent=self.agent,
250 artifact_service=ForwardingArtifactService(tool_context),
251 session_service=InMemorySessionService(),
252 memory_service=InMemoryMemoryService(),
253 credential_service=tool_context._invocation_context.credential_service,
254 plugins=plugins,
255 )
256 # When plugins are inherited from the parent runner, the parent still owns
257 # them; tell the sub-Runner's plugin manager to skip closing them on exit
258 # so shared plugins (e.g. observability exporters) are not torn down while
259 # the parent is still using them.
260 if self.include_plugins:
261 runner.plugin_manager.set_skip_closing_plugins(True)
262

Calls 15

run_asyncMethod · 0.95
closeMethod · 0.95
_get_input_schemaFunction · 0.85
RunnerClass · 0.85
_part_to_textFunction · 0.85
_get_output_schemaFunction · 0.85
validate_schemaFunction · 0.85
model_validateMethod · 0.80
model_dump_jsonMethod · 0.80