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

Method _new_invocation_context

src/google/adk/runners.py:1953–2004  ·  view source on GitHub ↗

Creates a new invocation context. Args: session: The session for the context. invocation_id: The invocation id for the context. new_message: The new message for the context. live_request_queue: The live request queue for the context. run_config: The run c

(
      self,
      session: Session,
      *,
      invocation_id: Optional[str] = None,
      new_message: Optional[types.Content] = None,
      live_request_queue: Optional[LiveRequestQueue] = None,
      run_config: Optional[RunConfig] = None,
  )

Source from the content-addressed store, hash-verified

1951 return InvocationContext(**kwargs)
1952
1953 def _new_invocation_context(
1954 self,
1955 session: Session,
1956 *,
1957 invocation_id: Optional[str] = None,
1958 new_message: Optional[types.Content] = None,
1959 live_request_queue: Optional[LiveRequestQueue] = None,
1960 run_config: Optional[RunConfig] = None,
1961 ) -> InvocationContext:
1962 """Creates a new invocation context.
1963
1964 Args:
1965 session: The session for the context.
1966 invocation_id: The invocation id for the context.
1967 new_message: The new message for the context.
1968 live_request_queue: The live request queue for the context.
1969 run_config: The run config for the context.
1970
1971 Returns:
1972 The new invocation context.
1973 """
1974 run_config = run_config or RunConfig()
1975 invocation_id = invocation_id or new_invocation_context_id()
1976
1977 if run_config.support_cfc and hasattr(self.agent, 'canonical_model'):
1978 model_name = self.agent.canonical_model.model
1979 if not model_name.startswith('gemini-2'):
1980 raise ValueError(
1981 f'CFC is not supported for model: {model_name} in agent:'
1982 f' {self.agent.name}'
1983 )
1984 if not isinstance(self.agent.code_executor, BuiltInCodeExecutor):
1985 self.agent.code_executor = BuiltInCodeExecutor()
1986
1987 return self._create_invocation_context(
1988 artifact_service=self.artifact_service,
1989 session_service=self.session_service,
1990 memory_service=self.memory_service,
1991 credential_service=self.credential_service,
1992 plugin_manager=self.plugin_manager,
1993 context_cache_config=self.context_cache_config,
1994 events_compaction_config=(
1995 self.app.events_compaction_config if self.app else None
1996 ),
1997 invocation_id=invocation_id,
1998 agent=self.agent if isinstance(self.agent, BaseAgent) else None,
1999 session=session,
2000 user_content=new_message,
2001 live_request_queue=live_request_queue,
2002 run_config=run_config,
2003 resumability_config=self.resumability_config,
2004 )
2005
2006 def _new_invocation_context_for_live(
2007 self,

Calls 4

RunConfigClass · 0.85
BuiltInCodeExecutorClass · 0.85