* Build an isolated messages array for a single parallel step. * The step sees the system prompt and its task description, but NOT * the full conversation history (which would include sibling results). * * IMPORTANT: sharedSystemMessages must contain ONLY {role:'system'} entries — * not user/as
(sharedSystemMessages, stepInstruction)
| 42 | * @returns {object[]} |
| 43 | */ |
| 44 | function buildStepMessages(sharedSystemMessages, stepInstruction) { |
| 45 | // Safety: only allow system messages to prevent history bleed |
| 46 | const systemOnly = (sharedSystemMessages || []).filter(m => m.role === 'system'); |
| 47 | return [ |
| 48 | ...systemOnly, |
| 49 | { role: 'user', content: stepInstruction }, |
| 50 | ]; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Execute a single batch of steps concurrently. |