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

Method _setup_context_for_new_invocation

src/google/adk/runners.py:1829–1867  ·  view source on GitHub ↗

Sets up the context for a new invocation. Args: session: The session to set up the invocation context for. new_message: The new message to process and append to the session. run_config: The run config of the agent. state_delta: Optional state changes to apply to the sess

(
      self,
      *,
      session: Session,
      new_message: types.Content,
      run_config: RunConfig,
      state_delta: Optional[dict[str, Any]],
  )

Source from the content-addressed store, hash-verified

1827 return collected_events
1828
1829 async def _setup_context_for_new_invocation(
1830 self,
1831 *,
1832 session: Session,
1833 new_message: types.Content,
1834 run_config: RunConfig,
1835 state_delta: Optional[dict[str, Any]],
1836 ) -> InvocationContext:
1837 """Sets up the context for a new invocation.
1838
1839 Args:
1840 session: The session to set up the invocation context for.
1841 new_message: The new message to process and append to the session.
1842 run_config: The run config of the agent.
1843 state_delta: Optional state changes to apply to the session.
1844
1845 Returns:
1846 The invocation context for the new invocation.
1847 """
1848 # Step 1: Create invocation context in memory.
1849 invocation_context = self._new_invocation_context(
1850 session,
1851 new_message=new_message,
1852 run_config=run_config,
1853 )
1854 # Step 2: Handle new message, by running callbacks and appending to
1855 # session.
1856 await self._handle_new_message(
1857 session=invocation_context.session,
1858 new_message=new_message,
1859 invocation_context=invocation_context,
1860 run_config=run_config,
1861 state_delta=state_delta,
1862 )
1863 # Step 3: Set agent to run for the invocation.
1864 invocation_context.agent = self._find_agent_to_run(
1865 invocation_context.session, self.agent
1866 )
1867 return invocation_context
1868
1869 async def _setup_context_for_resumed_invocation(
1870 self,

Callers 1

_run_with_traceMethod · 0.95

Calls 3

_handle_new_messageMethod · 0.95
_find_agent_to_runMethod · 0.95

Tested by

no test coverage detected