(
py: Python<'py>,
name: String,
args: &Bound<'py, PyAny>,
func: Py<PyAny>,
handle: Option<PyScopeHandle>,
attributes: Option<PyToolAttributes>,
data: Option<&Bound<'py, Py
| 489 | ) -> "object", text_signature = "(name: str, args: object, func: object, *, handle: ScopeHandle | None = None, attributes: ToolAttributes | None = None, data: object | None = None, metadata: object | None = None) -> object")] |
| 490 | #[allow(clippy::too_many_arguments)] |
| 491 | fn tool_call_execute<'py>( |
| 492 | py: Python<'py>, |
| 493 | name: String, |
| 494 | args: &Bound<'py, PyAny>, |
| 495 | func: Py<PyAny>, |
| 496 | handle: Option<PyScopeHandle>, |
| 497 | attributes: Option<PyToolAttributes>, |
| 498 | data: Option<&Bound<'py, PyAny>>, |
| 499 | metadata: Option<&Bound<'py, PyAny>>, |
| 500 | ) -> PyResult<Bound<'py, PyAny>> { |
| 501 | let args_json = py_to_json(args)?; |
| 502 | let attrs = attributes |
| 503 | .map(|a| a.inner) |
| 504 | .unwrap_or(ToolAttributes::empty()); |
| 505 | let data_json = opt_py_to_json(data)?; |
| 506 | let metadata_json = opt_py_to_json(metadata)?; |
| 507 | let exec_fn = py_callable::wrap_py_tool_exec_fn(func); |
| 508 | let default_fn: ToolExecutionNextFn = Arc::new(move |args| exec_fn(args)); |
| 509 | let parent_handle = handle.map(|h| h.inner).unwrap_or_else(task_scope_top); |
| 510 | |
| 511 | let scope_stack = current_scope_stack_handle(); |
| 512 | pyo3_async_runtimes::tokio::future_into_py(py, async move { |
| 513 | TASK_SCOPE_STACK |
| 514 | .scope(scope_stack, async move { |
| 515 | let result = core_tool_api::tool_call_execute( |
| 516 | core_tool_api::ToolCallExecuteParams::builder() |
| 517 | .name(name) |
| 518 | .args(args_json) |
| 519 | .func(default_fn) |
| 520 | .parent(parent_handle) |
| 521 | .attributes(attrs) |
| 522 | .data_opt(data_json) |
| 523 | .metadata_opt(metadata_json) |
| 524 | .build(), |
| 525 | ) |
| 526 | .await |
| 527 | .map_err(to_py_err)?; |
| 528 | Python::attach(|py| json_to_py(py, &result)) |
| 529 | }) |
| 530 | .await |
| 531 | }) |
| 532 | } |
| 533 | |
| 534 | // --------------------------------------------------------------------------- |
| 535 | // LLM lifecycle |
nothing calls this directly
no test coverage detected