Execute multiple tool calls while preserving request order, traceability, and isolated failures.
The full prompt is available without an account.
Implement batch_run(calls) where calls is a list of (fn, args) tuples.
For each call:
- fn is a callable (a tool function).
- args is a dict of keyword arguments to pass to the function.
Requirements:
- Execute each call sequentially in the order it appears in the list.
- Collect results into a list and return them in the same order.
- If any call raises an exception, append the exception object to the results list
(do NOT abort the entire batch).
- Return the full list of results (successful values and exceptions).
Read-only Python 3.12 preview. Sign in to edit and execute it.
from typing import Callable, Any
def batch_run(calls: list[tuple[Callable, dict]]) -> list[Any]:
# TODO: run each (fn, args) sequentially, collect results
return []