()
| 27 | |
| 28 | |
| 29 | def 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 | |
| 63 | if __name__ == "__main__": |
no test coverage detected