swarm-code 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/rlm.js +32 -1
- package/dist/prompts/orchestrator.js +3 -2
- package/package.json +1 -1
package/dist/core/rlm.js
CHANGED
|
@@ -373,6 +373,15 @@ export async function runRlmLoop(options) {
|
|
|
373
373
|
stderr: execResult.stderr,
|
|
374
374
|
});
|
|
375
375
|
if (execResult.hasFinal && execResult.finalValue !== null) {
|
|
376
|
+
// Auto-merge any unmerged thread branches before returning
|
|
377
|
+
if (mergeHandler) {
|
|
378
|
+
try {
|
|
379
|
+
await mergeHandler();
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
// Non-fatal — merge may have already been done by the LLM
|
|
383
|
+
}
|
|
384
|
+
}
|
|
376
385
|
return {
|
|
377
386
|
answer: execResult.finalValue,
|
|
378
387
|
iterations: iteration,
|
|
@@ -392,13 +401,35 @@ export async function runRlmLoop(options) {
|
|
|
392
401
|
parts.push("(No output produced. The code ran without printing anything.)");
|
|
393
402
|
}
|
|
394
403
|
parts.push(`\nIteration ${iteration}/${config.max_iterations}. Sub-queries used: ${totalSubQueries}/${config.max_sub_queries}.`);
|
|
395
|
-
|
|
404
|
+
const remaining = config.max_iterations - iteration;
|
|
405
|
+
if (remaining <= 2) {
|
|
406
|
+
parts.push("⚠️ CRITICAL: Only " +
|
|
407
|
+
remaining +
|
|
408
|
+
" iteration(s) remaining! Call merge_threads() then FINAL() NOW with your best result. Any unmerged work will be lost.");
|
|
409
|
+
}
|
|
410
|
+
else if (remaining <= Math.ceil(config.max_iterations * 0.25)) {
|
|
411
|
+
parts.push("⚠️ WARNING: " +
|
|
412
|
+
remaining +
|
|
413
|
+
" iterations remaining. Wrap up: merge_threads() → FINAL(). Don't start new threads.");
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
parts.push("Continue processing or call FINAL() when you have the answer.");
|
|
417
|
+
}
|
|
396
418
|
conversationHistory.push({
|
|
397
419
|
role: "user",
|
|
398
420
|
content: parts.join("\n\n"),
|
|
399
421
|
timestamp: Date.now(),
|
|
400
422
|
});
|
|
401
423
|
}
|
|
424
|
+
// Auto-merge any remaining thread branches even though FINAL was never called
|
|
425
|
+
if (mergeHandler) {
|
|
426
|
+
try {
|
|
427
|
+
await mergeHandler();
|
|
428
|
+
}
|
|
429
|
+
catch {
|
|
430
|
+
// Non-fatal
|
|
431
|
+
}
|
|
432
|
+
}
|
|
402
433
|
return {
|
|
403
434
|
answer: "[Maximum iterations reached without calling FINAL]",
|
|
404
435
|
iterations: config.max_iterations,
|
|
@@ -77,9 +77,10 @@ ${agentDescriptions}
|
|
|
77
77
|
4. Use \`print()\` for intermediate output visible in the next iteration
|
|
78
78
|
5. Max ${config.max_threads} concurrent threads, ${config.max_total_threads} total per session
|
|
79
79
|
6. Thread timeout: ${config.thread_timeout_ms / 1000}s per thread
|
|
80
|
-
7.
|
|
80
|
+
7. After merging, try to run a quick verification thread if iterations allow. But don't endlessly loop on verification — one attempt is enough.
|
|
81
81
|
8. Prefer cheap models for sub-agent threads (haiku, gpt-4o-mini) — save premium models for complex work
|
|
82
|
-
|
|
82
|
+
9. The REPL persists state — variables survive across iterations
|
|
83
|
+
10. **Watch your iteration count.** If you're past 75% of max iterations, call \`merge_threads()\` then \`FINAL()\` with your best result. Don't waste iterations on repeated verification cycles.
|
|
83
84
|
|
|
84
85
|
## Examples
|
|
85
86
|
|
package/package.json
CHANGED