Handles a new message by running callbacks and appending to session. Args: session: The session of the new message. new_message: The new message to process and append to the session. invocation_context: The invocation context to use for the message handling. run_
(
self,
*,
session: Session,
new_message: types.Content,
invocation_context: InvocationContext,
run_config: RunConfig,
state_delta: Optional[dict[str, Any]],
)
| 2030 | ) |
| 2031 | |
| 2032 | async def _handle_new_message( |
| 2033 | self, |
| 2034 | *, |
| 2035 | session: Session, |
| 2036 | new_message: types.Content, |
| 2037 | invocation_context: InvocationContext, |
| 2038 | run_config: RunConfig, |
| 2039 | state_delta: Optional[dict[str, Any]], |
| 2040 | ) -> None: |
| 2041 | """Handles a new message by running callbacks and appending to session. |
| 2042 | |
| 2043 | Args: |
| 2044 | session: The session of the new message. |
| 2045 | new_message: The new message to process and append to the session. |
| 2046 | invocation_context: The invocation context to use for the message |
| 2047 | handling. |
| 2048 | run_config: The run config of the agent. |
| 2049 | state_delta: Optional state changes to apply to the session. |
| 2050 | """ |
| 2051 | modified_user_message = ( |
| 2052 | await invocation_context.plugin_manager.run_on_user_message_callback( |
| 2053 | invocation_context=invocation_context, user_message=new_message |
| 2054 | ) |
| 2055 | ) |
| 2056 | if modified_user_message is not None: |
| 2057 | new_message = modified_user_message |
| 2058 | invocation_context.user_content = new_message |
| 2059 | |
| 2060 | if new_message: |
| 2061 | deprecated_save_blobs = False |
| 2062 | if 'save_input_blobs_as_artifacts' in run_config.model_fields_set: |
| 2063 | deprecated_save_blobs = run_config.save_input_blobs_as_artifacts |
| 2064 | await self._append_new_message_to_session( |
| 2065 | session=invocation_context.session, |
| 2066 | new_message=new_message, |
| 2067 | invocation_context=invocation_context, |
| 2068 | save_input_blobs_as_artifacts=deprecated_save_blobs, |
| 2069 | state_delta=state_delta, |
| 2070 | ) |
| 2071 | |
| 2072 | def _collect_toolset(self, agent: BaseAgent) -> set[BaseToolset]: |
| 2073 | toolsets = set() |
no test coverage detected