diff --git a/backend/services/bot_service.py b/backend/services/bot_service.py index 639ce6e..457163d 100644 --- a/backend/services/bot_service.py +++ b/backend/services/bot_service.py @@ -465,6 +465,10 @@ def serialize_bot_list_entry(bot: BotInstance) -> Dict[str, Any]: } +def _has_bot_workspace_config(bot_id: str) -> bool: + return (Path(BOTS_WORKSPACE_ROOT) / bot_id / ".nanobot" / "config.json").is_file() + + def sync_bot_workspace_channels( session: Session, bot_id: str, @@ -476,8 +480,14 @@ def sync_bot_workspace_channels( if not bot: raise RuntimeError(f"Bot not found: {bot_id}") - snapshot = read_bot_runtime_snapshot(bot) - bot_data: Dict[str, Any] = dict(snapshot) + has_existing_config = _has_bot_workspace_config(bot_id) + if has_existing_config: + snapshot = read_bot_runtime_snapshot(bot) + bot_data: Dict[str, Any] = dict(snapshot) + else: + if not isinstance(runtime_overrides, dict): + raise RuntimeError(f"Missing required bot config for workspace sync: {bot_id}") + bot_data = {} if isinstance(runtime_overrides, dict): bot_data.update(runtime_overrides) @@ -495,7 +505,12 @@ def sync_bot_workspace_channels( if "sendToolHints" in global_delivery_override: send_tool_hints = bool(global_delivery_override.get("sendToolHints")) - channels_data = channels_override if channels_override is not None else list_bot_channels_from_config(bot) + if channels_override is not None: + channels_data = channels_override + elif has_existing_config: + channels_data = list_bot_channels_from_config(bot) + else: + channels_data = [] bot_data["send_progress"] = send_progress bot_data["send_tool_hints"] = send_tool_hints normalized_channels: List[Dict[str, Any]] = []