fix: preserve exploration demonstration source and recording scope

This commit is contained in:
chenmingxuan committed 2026-10-18 23:20:50 +08:00
1 parent f4cb55c030
commit 973ccae679
22 files changed
+624 -55

No files matched your search

+32 -1
View File
@@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest.mock import Mock, patch
from types import SimpleNamespace
from unittest.mock import AsyncMock, Mock, patch
from artemis.agents.planner.planner import PlannerNode
from artemis.context import DevicePlatform, ArtemisContext
@@ -97,6 +98,36 @@ async def test_planner_initial_plan(mock_context):
assert "Goal: Test Goal" in human_msg_content[0]["text"]
@pytest.mark.asyncio
@pytest.mark.parametrize("target", ["mixed", "computer"])
async def test_planner_knows_computer_plugins_with_mobile_primary_screen(mock_context, target):
state = DummyState(initial_goal="按人工示范浏览首页")
mock_context.execution_target = target
mock_context.plugins = SimpleNamespace(prompt=lambda: "电脑插件:cua-driver,可按需加载")
controller = Mock()
controller.take_screenshot = AsyncMock(return_value=_valid_screen_base64())
controller.get_screen_data = AsyncMock(
return_value=SimpleNamespace(observation_text="电脑窗口状态")
)
llm = Mock()
async def stream(*_args, **_kwargs):
yield SimpleNamespace(content="- [ ] 浏览首页", tool_calls=[])
llm.astream.side_effect = stream
llm.bind_tools.return_value = llm
with (
patch("artemis.agents.planner.planner.get_llm", return_value=llm),
patch("artemis.agents.planner.planner.UnifiedMobileController", return_value=controller),
):
await PlannerNode(mock_context)(state)
content = llm.astream.call_args.args[0][1].content
text = "\n".join(part["text"] for part in content if part["type"] == "text")
assert text.count("电脑插件:cua-driver") == 1
assert f"当前主设备截图({'电脑' if target == 'computer' else '安卓'})" in text
assert "不决定其他步骤的执行平台" in text
def test_validate_plan_format_single_sourced_status_alphabet():
"""Regression: the Planner's format gate is single-sourced from
plan_grammar — a legal in-progress '[/]' line must never be rejected."""