| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import pytest
- import agent.client as client_module
- @pytest.mark.asyncio
- async def test_invoke_agent_forwards_root_task_spec_only_to_local_runner(monkeypatch):
- captured = {}
- async def fake_local(**kwargs):
- captured.update(kwargs)
- return {"mode": "local", "status": "completed"}
- monkeypatch.setattr(client_module, "_run_local_agent", fake_local)
- root_task_spec = {
- "objective": "Complete the mission",
- "acceptance_criteria": [
- {"criterion_id": "done", "description": "Mission is complete"}
- ],
- }
- result = await client_module.invoke_agent(
- agent_type="planner",
- task="start",
- project_root="/project",
- root_task_spec=root_task_spec,
- )
- assert result["status"] == "completed"
- assert captured["root_task_spec"] is root_task_spec
- @pytest.mark.asyncio
- async def test_invoke_agent_rejects_remote_root_task_spec():
- result = await client_module.invoke_agent(
- agent_type="remote_planner",
- task="start",
- root_task_spec={"objective": "must stay local"},
- )
- assert result["mode"] == "remote"
- assert result["status"] == "failed"
- assert "root_task_spec" in result["error"]
- assert "本地" in result["error"]
|