MCPcopy
hub / github.com/langroid/langroid / add_sub_task

Method add_sub_task

langroid/agent/task.py:572–608  ·  view source on GitHub ↗

Add a sub-task (or list of subtasks) that this task can delegate (or fail-over) to. Note that the sequence of sub-tasks is important, since these are tried in order, as the parent task searches for a valid response (unless a sub-task is explicitly addressed).

(
        self,
        task: (
            Task | List[Task] | Tuple[Task, TaskConfig] | List[Tuple[Task, TaskConfig]]
        ),
    )

Source from the content-addressed store, hash-verified

570 return self._indent + "<<<"
571
572 def add_sub_task(
573 self,
574 task: (
575 Task | List[Task] | Tuple[Task, TaskConfig] | List[Tuple[Task, TaskConfig]]
576 ),
577 ) -> None:
578 """
579 Add a sub-task (or list of subtasks) that this task can delegate
580 (or fail-over) to. Note that the sequence of sub-tasks is important,
581 since these are tried in order, as the parent task searches for a valid
582 response (unless a sub-task is explicitly addressed).
583
584 Args:
585 task: A task, or list of tasks, or a tuple of task and task config,
586 or a list of tuples of task and task config.
587 These tasks are added as sub-tasks of the current task.
588 The task configs (if any) dictate how the tasks are run when
589 invoked as sub-tasks of other tasks. This allows users to specify
590 behavior applicable only in the context of a particular task-subtask
591 combination.
592 """
593 if isinstance(task, list):
594 for t in task:
595 self.add_sub_task(t)
596 return
597
598 if isinstance(task, tuple):
599 task, config = task
600 else:
601 config = TaskConfig()
602 task.config_sub_task = config
603 self.sub_tasks.append(task)
604 self.name_sub_task_map[task.name] = task
605 self.responders.append(cast(Responder, task))
606 self.responders_async.append(cast(Responder, task))
607 self.non_human_responders.append(cast(Responder, task))
608 self.non_human_responders_async.append(cast(Responder, task))
609
610 def init(self, msg: None | str | ChatDocument = None) -> ChatDocument | None:
611 """

Callers 15

newMethod · 0.95
test_addressingFunction · 0.95
test_agent_done_toolFunction · 0.95
test_orch_toolsFunction · 0.95
test_orch_tools_asyncFunction · 0.95
test_send_toolsFunction · 0.95
test_inter_agent_chatFunction · 0.95
test_multi_agentFunction · 0.95

Calls 1

TaskConfigClass · 0.85

Tested by 15

test_addressingFunction · 0.76
test_agent_done_toolFunction · 0.76
test_orch_toolsFunction · 0.76
test_orch_tools_asyncFunction · 0.76
test_send_toolsFunction · 0.76
test_inter_agent_chatFunction · 0.76
test_multi_agentFunction · 0.76