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

Method delegate_task

sdk/python/src/lib.rs:1961–1987  ·  view source on GitHub ↗
(
        &self,
        py: Python<'_>,
        agent: String,
        description: String,
        prompt: String,
        background: bool,
        max_steps: Option<u32>,
    )

Source from the content-addressed store, hash-verified

1959 /// Delegate a bounded task to a child agent through the built-in ``task`` tool.
1960 #[pyo3(signature = (agent, description, prompt, background=false, max_steps=None))]
1961 fn delegate_task(
1962 &self,
1963 py: Python<'_>,
1964 agent: String,
1965 description: String,
1966 prompt: String,
1967 background: bool,
1968 max_steps: Option<u32>,
1969 ) -> PyResult<PyToolResult> {
1970 let args = delegate_task_args(agent, description, prompt, background, max_steps);
1971
1972 let session = self.inner.clone();
1973 let result = py
1974 .allow_threads(move || get_runtime().block_on(session.tool("task", args)))
1975 .map_err(|e| PyRuntimeError::new_err(format!("Task delegation failed: {e}")))?;
1976
1977 Ok(PyToolResult {
1978 name: result.name,
1979 output: result.output,
1980 exit_code: result.exit_code,
1981 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
1982 error_kind_json: result
1983 .error_kind
1984 .as_ref()
1985 .and_then(|k| serde_json::to_string(k).ok()),
1986 })
1987 }
1988
1989 /// Execute several delegated child-agent tasks with the compact API.
1990 fn tasks(&self, py: Python<'_>, tasks: &Bound<'_, PyAny>) -> PyResult<PyToolResult> {

Callers 1

Calls 5

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

Tested by

no test coverage detected