Function: createDispatchReasoner()
function createDispatchReasoner(options: {
executor: DispatchExecutorFn;
spoolStore?: InMemorySpoolStore;
toolName?: string;
}): ReasonerFn;Defined in: src/batteries/orchestration/dispatch_reasoner.ts:104
Builds a reasoner that answers through a forced tool dispatch.
A reasoning node must return a structured, schema-validated result, but DispatchRunner.dispatch resolves to void. This helper bridges that gap by wiring the node's output schema onto a forced tool's inputSchema and capturing the arguments the model submits to that tool. Because the tool's input schema is the node's output schema, validation rejects malformed arguments before the handler ever runs, so the model cannot answer with unstructured prose.
The captured value is read from a closure after the dispatch resolves; the void return value is irrelevant. If the tool is never called, the dispatch is a halting failure and this function throws rather than fabricating or returning a partial result.
The boundary this draws is deliberate: the battery owns the forced-tool protocol and the retry bound, and the CONSUMER owns the model. DispatchRunner takes an injected executor rather than a model identifier, so a consumer wires whichever provider they already use and this helper never grows credential handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | { executor: DispatchExecutorFn; spoolStore?: InMemorySpoolStore; toolName?: string; } | Configuration for the reasoner. |
options.executor | DispatchExecutorFn | The consumer's LLM call, invoked by the runner on every iteration. |
options.spoolStore? | InMemorySpoolStore | Store used to spool large results. Defaults to a fresh InMemorySpoolStore so a large reasoning result always has somewhere to go. |
options.toolName? | string | Name of the forced capture tool. Defaults to 'submit_reasoning'. |
Returns
A ReasonerFn that resolves to the validated reasoning result or throws if no valid result could be captured.