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

Method tasks

sdk/python/src/lib.rs:1990–2014  ·  view source on GitHub ↗

Execute several delegated child-agent tasks with the compact API.

(&self, py: Python<'_>, tasks: &Bound<'_, PyAny>)

Source from the content-addressed store, hash-verified

1988
1989 /// Execute several delegated child-agent tasks with the compact API.
1990 fn tasks(&self, py: Python<'_>, tasks: &Bound<'_, PyAny>) -> PyResult<PyToolResult> {
1991 let json_mod = py.import("json")?;
1992 let json_str: String = json_mod.call_method1("dumps", (tasks,))?.extract()?;
1993 let task_values: serde_json::Value = serde_json::from_str(&json_str)
1994 .map_err(|e| PyValueError::new_err(format!("Invalid task list: {e}")))?;
1995 let args = parallel_task_args(task_values)?;
1996
1997 let session = self.inner.clone();
1998 let result = py
1999 .allow_threads(move || get_runtime().block_on(session.tool("parallel_task", args)))
2000 .map_err(|e| {
2001 PyRuntimeError::new_err(format!("Parallel task delegation failed: {e}"))
2002 })?;
2003
2004 Ok(PyToolResult {
2005 name: result.name,
2006 output: result.output,
2007 exit_code: result.exit_code,
2008 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
2009 error_kind_json: result
2010 .error_kind
2011 .as_ref()
2012 .and_then(|k| serde_json::to_string(k).ok()),
2013 })
2014 }
2015
2016 /// Execute several delegated child-agent tasks concurrently through ``parallel_task``.
2017 fn parallel_task(&self, py: Python<'_>, tasks: &Bound<'_, PyAny>) -> PyResult<PyToolResult> {

Callers 1

parallel_taskMethod · 0.45

Calls 5

parallel_task_argsFunction · 0.85
block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
toolMethod · 0.45

Tested by

no test coverage detected