MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / test_control_plan

Function test_control_plan

tests/server/test_agent_server_e2e.py:791–824  ·  view source on GitHub ↗

plan set/view/clear round-trips and injects into the system prompt.

(tmp_path)

Source from the content-addressed store, hash-verified

789
790@pytest.mark.asyncio
791async def test_control_plan(tmp_path):
792 """plan set/view/clear round-trips and injects into the system prompt."""
793 from src.tool_system.registry import ToolRegistry
794
795 with contextlib.ExitStack() as stack:
796 for p in _patches(_TextProvider, ToolRegistry([])):
797 stack.enter_context(p)
798 spawn = make_spawn_agent(AgentServerConfig(permission_mode="default"))
799 handle = await spawn("ds_test", str(tmp_path), None)
800 gen = handle.messages_from_agent()
801 try:
802 init = await asyncio.wait_for(gen.__anext__(), timeout=5)
803 assert init["subtype"] == "init"
804
805 async def _reply_for(rid, req):
806 await handle.send_to_agent({"type": "control_request", "request_id": rid, "request": req})
807 for _ in range(12):
808 msg = await asyncio.wait_for(gen.__anext__(), timeout=5)
809 if msg.get("type") == "control_response" and msg["response"].get("request_id") == rid:
810 return msg["response"]["response"]
811 raise AssertionError(f"no reply for {rid}")
812
813 empty = await _reply_for("p0", {"subtype": "plan", "action": "view"})
814 assert empty["plan"] == ""
815 setr = await _reply_for("p1", {"subtype": "plan", "action": "set", "text": "ship v2"})
816 assert setr["ok"] is True and "ship v2" in setr["plan"]
817 view = await _reply_for("p2", {"subtype": "plan", "action": "view"})
818 assert "ship v2" in view["plan"]
819 cleared = await _reply_for("p3", {"subtype": "plan", "action": "clear"})
820 assert cleared["plan"] == ""
821 finally:
822 await handle.shutdown()
823 with contextlib.suppress(Exception):
824 await gen.aclose()
825
826
827@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 9

ToolRegistryClass · 0.90
make_spawn_agentFunction · 0.90
AgentServerConfigClass · 0.90
_patchesFunction · 0.85
_reply_forFunction · 0.85
__anext__Method · 0.80
spawnFunction · 0.70
shutdownMethod · 0.45
acloseMethod · 0.45

Tested by

no test coverage detected