The Runner class is used to run agents. It manages the execution of an agent within a session, handling message processing, event generation, and interaction with various services like artifact storage, session management, and memory. Attributes: app_name: The application name of the
| 130 | |
| 131 | |
| 132 | class Runner: |
| 133 | """The Runner class is used to run agents. |
| 134 | |
| 135 | It manages the execution of an agent within a session, handling message |
| 136 | processing, event generation, and interaction with various services like |
| 137 | artifact storage, session management, and memory. |
| 138 | |
| 139 | Attributes: |
| 140 | app_name: The application name of the runner. |
| 141 | agent: The root agent to run. |
| 142 | artifact_service: The artifact service for the runner. |
| 143 | plugin_manager: The plugin manager for the runner. |
| 144 | session_service: The session service for the runner. |
| 145 | memory_service: The memory service for the runner. |
| 146 | credential_service: The credential service for the runner. |
| 147 | context_cache_config: The context cache config for the runner. |
| 148 | resumability_config: The resumability config for the application. |
| 149 | """ |
| 150 | |
| 151 | app_name: str |
| 152 | """The app name of the runner.""" |
| 153 | agent: Optional[BaseAgent | 'BaseNode'] = None |
| 154 | """The root agent or node to run.""" |
| 155 | artifact_service: Optional[BaseArtifactService] = None |
| 156 | """The artifact service for the runner.""" |
| 157 | plugin_manager: PluginManager |
| 158 | """The plugin manager for the runner.""" |
| 159 | session_service: BaseSessionService |
| 160 | """The session service for the runner.""" |
| 161 | memory_service: Optional[BaseMemoryService] = None |
| 162 | """The memory service for the runner.""" |
| 163 | credential_service: Optional[BaseCredentialService] = None |
| 164 | """The credential service for the runner.""" |
| 165 | context_cache_config: Optional[ContextCacheConfig] = None |
| 166 | """The context cache config for the runner.""" |
| 167 | resumability_config: Optional[ResumabilityConfig] = None |
| 168 | """The resumability config for the application.""" |
| 169 | |
| 170 | def __init__( |
| 171 | self, |
| 172 | *, |
| 173 | app: Optional[App] = None, |
| 174 | app_name: Optional[str] = None, |
| 175 | agent: Optional[BaseAgent] = None, |
| 176 | node: Any = None, |
| 177 | plugins: Optional[List[BasePlugin]] = None, |
| 178 | artifact_service: Optional[BaseArtifactService] = None, |
| 179 | session_service: BaseSessionService, |
| 180 | memory_service: Optional[BaseMemoryService] = None, |
| 181 | credential_service: Optional[BaseCredentialService] = None, |
| 182 | plugin_close_timeout: float = 5.0, |
| 183 | auto_create_session: bool = False, |
| 184 | ): |
| 185 | """Initializes the Runner. |
| 186 | |
| 187 | Exactly one of `app`, `agent`, or `node` must be provided. When `agent` |
| 188 | or `node` is provided, the Runner wraps it into an `App` internally. |
| 189 | Providing `app` is the recommended way to create a runner. When `app` is |
no outgoing calls