An in-memory Runner for testing and development. This runner uses in-memory implementations for artifact, session, and memory services, providing a lightweight and self-contained environment for agent execution. Attributes: agent: The root agent to run. app_name: The applicatio
| 2143 | |
| 2144 | |
| 2145 | class InMemoryRunner(Runner): |
| 2146 | """An in-memory Runner for testing and development. |
| 2147 | |
| 2148 | This runner uses in-memory implementations for artifact, session, and memory |
| 2149 | services, providing a lightweight and self-contained environment for agent |
| 2150 | execution. |
| 2151 | |
| 2152 | Attributes: |
| 2153 | agent: The root agent to run. |
| 2154 | app_name: The application name of the runner. Defaults to |
| 2155 | 'InMemoryRunner'. |
| 2156 | """ |
| 2157 | |
| 2158 | def __init__( |
| 2159 | self, |
| 2160 | agent: Optional[BaseAgent] = None, |
| 2161 | *, |
| 2162 | node: Any = None, |
| 2163 | app_name: Optional[str] = None, |
| 2164 | plugins: Optional[list[BasePlugin]] = None, |
| 2165 | app: Optional[App] = None, |
| 2166 | plugin_close_timeout: float = 5.0, |
| 2167 | ): |
| 2168 | """Initializes the InMemoryRunner. |
| 2169 | |
| 2170 | Args: |
| 2171 | agent: The root agent to run. |
| 2172 | node: The root node to run. |
| 2173 | app_name: The application name of the runner. Defaults to |
| 2174 | 'InMemoryRunner'. |
| 2175 | plugins: Optional list of plugins for the runner. |
| 2176 | app: Optional App instance. |
| 2177 | plugin_close_timeout: The timeout in seconds for plugin close methods. |
| 2178 | """ |
| 2179 | from .artifacts.in_memory_artifact_service import InMemoryArtifactService |
| 2180 | from .memory.in_memory_memory_service import InMemoryMemoryService |
| 2181 | from .sessions.in_memory_session_service import InMemorySessionService |
| 2182 | |
| 2183 | if app is None and app_name is None: |
| 2184 | app_name = 'InMemoryRunner' |
| 2185 | super().__init__( |
| 2186 | app_name=app_name, |
| 2187 | agent=agent, |
| 2188 | node=node, |
| 2189 | artifact_service=InMemoryArtifactService(), |
| 2190 | plugins=plugins, |
| 2191 | app=app, |
| 2192 | session_service=InMemorySessionService(), |
| 2193 | memory_service=InMemoryMemoryService(), |
| 2194 | plugin_close_timeout=plugin_close_timeout, |
| 2195 | ) |
no outgoing calls