Serialize app information for the build_graph endpoint.
(app: Any, readme: str | None = None)
| 251 | |
| 252 | |
| 253 | def serialize_app_info(app: Any, readme: str | None = None) -> dict[str, Any]: |
| 254 | """Serialize app information for the build_graph endpoint.""" |
| 255 | root = app.root_agent |
| 256 | try: |
| 257 | root_agent_data = serialize_agent(root) |
| 258 | except Exception as e: |
| 259 | logger.error("Error serializing root agent/node: %s", e, exc_info=True) |
| 260 | raise |
| 261 | |
| 262 | app_info = { |
| 263 | "name": app.name, |
| 264 | "root_agent": root_agent_data, |
| 265 | } |
| 266 | |
| 267 | # Add optional fields if present |
| 268 | if app.plugins: |
| 269 | app_info["plugins"] = [ |
| 270 | {"name": getattr(plugin, "name", type(plugin).__name__)} |
| 271 | for plugin in app.plugins |
| 272 | ] |
| 273 | |
| 274 | if app.context_cache_config: |
| 275 | try: |
| 276 | app_info["context_cache_config"] = app.context_cache_config.model_dump( |
| 277 | mode="python", exclude_none=True |
| 278 | ) |
| 279 | except Exception: |
| 280 | pass |
| 281 | |
| 282 | if app.resumability_config: |
| 283 | try: |
| 284 | app_info["resumability_config"] = app.resumability_config.model_dump( |
| 285 | mode="python", exclude_none=True |
| 286 | ) |
| 287 | except Exception: |
| 288 | pass |
| 289 | |
| 290 | # Include README content if provided |
| 291 | if readme: |
| 292 | app_info["readme"] = readme |
| 293 | |
| 294 | return app_info |
no test coverage detected