ParallelToolRunner

class ParallelToolRunner(tracer: Tracer = NullTracer, caller: String? = null, maxConcurrency: Int = 4) : ToolRunner

Parallel tool runner — fans out tool calls onto child coroutines and waits for all of them. Opt-in alternative to SerialToolRunner.

Per-call wall-clock duration still lands on each ToolOutcome; the runner additionally emits a single com.mojentic.tracer.ToolBatchEvent via tracer summarising the batch (size, success / failure counts, aggregate latency) so observers can quantify parallelism gains.

At most maxConcurrency calls execute at once; outcomes keep request order. A call naming an unknown tool yields an error outcome in its slot.

Cancellation propagates cooperatively: cancelling the calling coroutine cancels every in-flight child via coroutineScope.

Throws

Constructors

Link copied to clipboard
constructor(tracer: Tracer = NullTracer, caller: String? = null, maxConcurrency: Int = 4)

Functions

Link copied to clipboard
open suspend override fun runBatch(calls: List<LlmToolCall>, tools: List<LlmTool>, correlationId: String? = null): List<ToolOutcome>

Execute calls against tools, returning outcomes in input order.