From 9e3007e7f6648988cb8d5ade8bc5c8d1119139d0 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 21 Jul 2026 14:32:44 +0800 Subject: [PATCH] feat(cloud): accept mcp_busy_device_ids in heartbeat payload --- .../cloud/internal_api/models.py | 1 + .../tests/test_internal_api_models.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 packages/cloud-platform/tests/test_internal_api_models.py diff --git a/packages/cloud-platform/cloud/internal_api/models.py b/packages/cloud-platform/cloud/internal_api/models.py index b72049c..87bf7b3 100644 --- a/packages/cloud-platform/cloud/internal_api/models.py +++ b/packages/cloud-platform/cloud/internal_api/models.py @@ -40,6 +40,7 @@ class HeartbeatRequest(BaseModel): devices: list[DeviceSnapshotModel] = Field(default_factory=list) policy_revision: int = Field(default=0, ge=0) planner_transport: Literal["direct", "cloud"] = "direct" + mcp_busy_device_ids: list[str] = Field(default_factory=list) class HostGovernancePolicyModel(BaseModel): diff --git a/packages/cloud-platform/tests/test_internal_api_models.py b/packages/cloud-platform/tests/test_internal_api_models.py new file mode 100644 index 0000000..b73e26c --- /dev/null +++ b/packages/cloud-platform/tests/test_internal_api_models.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +from cloud.internal_api.models import HeartbeatRequest + + +def test_heartbeat_request_defaults_mcp_busy_device_ids_to_empty() -> None: + req = HeartbeatRequest(host_id="h1") + assert req.mcp_busy_device_ids == [] + + +def test_heartbeat_request_accepts_mcp_busy_device_ids() -> None: + req = HeartbeatRequest(host_id="h1", mcp_busy_device_ids=["phone-1"]) + assert req.mcp_busy_device_ids == ["phone-1"] + + +def test_heartbeat_request_omitting_field_is_backward_compatible() -> None: + """Old host-agents that don't send the field must still validate.""" + raw = {"host_id": "h1", "devices": []} + req = HeartbeatRequest.model_validate(raw) + assert req.mcp_busy_device_ids == []