MCPcopy Index your code
hub / github.com/Doorman11991/smallcode / runParallelPlan

Function runParallelPlan

src/session/parallel_executor.js:157–192  ·  view source on GitHub ↗

* Run a full plan through the parallel executor. * Processes batches in order; within each batch, steps run concurrently. * * @param {number[][]} batches - from toParallelBatches() * @param {string[]} planSteps - all plan step texts * @param {object[]} systemMessages - shared system prompt mess

(
  batches,
  planSteps,
  systemMessages,
  chatCompletionFn,
  executeToolFn,
  config,
  ctx,
  onBatchComplete,
)

Source from the content-addressed store, hash-verified

155 * @returns {Promise<Array<{stepIndex, content, toolResults}>>}
156 */
157async function runParallelPlan(
158 batches,
159 planSteps,
160 systemMessages,
161 chatCompletionFn,
162 executeToolFn,
163 config,
164 ctx,
165 onBatchComplete,
166) {
167 const allResults = [];
168
169 for (let batchIdx = 0; batchIdx < batches.length; batchIdx++) {
170 const batch = batches[batchIdx];
171 const batchResults = await executeBatch(
172 batch,
173 planSteps,
174 systemMessages,
175 chatCompletionFn,
176 executeToolFn,
177 config,
178 ctx,
179 );
180
181 for (const r of batchResults) {
182 allResults[r.stepIndex] = r;
183 }
184
185 if (typeof onBatchComplete === 'function') {
186 try { onBatchComplete(batchIdx, batchResults); } catch {}
187 }
188 }
189
190 // Return results sorted by original step order
191 return allResults.filter(Boolean);
192}
193
194/**
195 * Merge parallel execution results into a single conversationHistory entry.

Callers

nothing calls this directly

Calls 1

executeBatchFunction · 0.85

Tested by

no test coverage detected