MCPcopy Create free account
hub / github.com/modelscope/ms-agent / SplitTask

Class SplitTask

ms_agent/tools/split_task.py:11–140  ·  view source on GitHub ↗

A tool special for task splitting

Source from the content-addressed store, hash-verified

9
10
11class SplitTask(ToolBase):
12 """A tool special for task splitting"""
13
14 def __init__(self, config: DictConfig, **kwargs):
15 super().__init__(config)
16 if hasattr(config, 'tools') and hasattr(config.tools, 'split_task'):
17 self.tag_prefix = getattr(config.tools.split_task, 'tag_prefix',
18 'worker-')
19 else:
20 self.tag_prefix = kwargs.get('tag_prefix', 'worker-')
21 self.round = 0
22
23 async def connect(self):
24 pass
25
26 async def cleanup(self):
27 pass
28
29 async def _get_tools_inner(self):
30 return {
31 'split_task': [
32 Tool(
33 tool_name='split_to_sub_task',
34 server_name='split_task',
35 description=
36 'Split complex task into sub tasks and start them, for example, '
37 'split a website generation task into sub tasks, '
38 'you plan the framework, include code files and classes and functions, and give the detail '
39 'information to the system and query field of the subtask, then '
40 'let each subtask to write a single file',
41 parameters={
42 'type': 'object',
43 'properties': {
44 'tasks': {
45 'type':
46 'array',
47 'description':
48 'MANDATORY: Each element is a dict, which must contains two fields: '
49 '`system`(str) and `query`(str) to start one sub task.'
50 }
51 },
52 'required': ['tasks'],
53 'additionalProperties': False
54 })
55 ]
56 }
57
58 async def call_tool(self, server_name: str, *, tool_name: str,
59 tool_args: dict):
60 """
61 1. LLMAgent will be used to start subtask
62 2. config will be inherited from the parent task
63 3. Supports both parallel and sequential execution modes
64 """
65 from ms_agent.agent import LLMAgent
66
67 tasks = tool_args.get('tasks')
68 execution_mode = tool_args.get(

Callers 2

__init__Method · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected