MCPcopy Index your code
hub / github.com/AI45Lab/Code / main

Function main

sdk/python/tests/test_subagent_query_api.py:29–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28
29def main() -> None:
30 workspace = tempfile.mkdtemp(prefix="a3s-code-python-subagent-")
31 agent = Agent.create(INLINE_CONFIG)
32
33 opts = SessionOptions()
34 opts.permission_policy = PermissionPolicy(default_decision="allow")
35 opts.workspace_backend = LocalWorkspaceBackend(workspace)
36
37 session = agent.session(workspace, opts)
38
39 tasks = session.subagent_tasks()
40 assert isinstance(tasks, list), f"subagent_tasks() should return list, got {type(tasks)!r}"
41 assert tasks == [], f"fresh session should have no subagent tasks, got {tasks!r}"
42
43 pending = session.pending_subagent_tasks()
44 assert isinstance(
45 pending, list
46 ), f"pending_subagent_tasks() should return list, got {type(pending)!r}"
47 assert (
48 pending == []
49 ), f"fresh session should have no pending subagent tasks, got {pending!r}"
50
51 missing = session.subagent_task("task-does-not-exist")
52 assert missing is None, f"unknown subagent task id should return None, got {missing!r}"
53
54 cancelled = session.cancel_subagent_task("task-does-not-exist")
55 assert cancelled is False, (
56 f"cancelling unknown subagent task id should return False, got {cancelled!r}"
57 )
58
59 session.close()
60 print("python sdk subagent query api ok")
61
62
63if __name__ == "__main__":

Callers 1

Calls 10

SessionOptionsClass · 0.50
PermissionPolicyClass · 0.50
createMethod · 0.45
sessionMethod · 0.45
subagent_tasksMethod · 0.45
subagent_taskMethod · 0.45
cancel_subagent_taskMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected