openzoo 0.48.8 → 0.48.9

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.
Files changed (2) hide show
  1. package/lib/grokui.mjs +28 -1
  2. package/package.json +1 -1
package/lib/grokui.mjs CHANGED
@@ -336,6 +336,10 @@ function newGroupThread(names) {
336
336
  const BIND_CHUNK_BYTES = 512 * 1024;
337
337
  // Chained auto-run commands per user message. Each hop is a paid call.
338
338
  const AUTO_MAX_STEPS = Number(process.env.OZ_AUTO_MAX_STEPS || 8);
339
+ // Ceiling on subagents per thread. Spawning is fire-and-forget and each child
340
+ // can spawn too, so without a count it is unbounded — MEASURED as 15+ threads
341
+ // all named tetris-contract, every one of them a live agent making paid calls.
342
+ const SPAWN_MAX_CHILDREN = Number(process.env.OZ_SPAWN_MAX_CHILDREN || 12);
339
343
 
340
344
  // Injected fresh on every AUTO turn, never persisted into the thread.
341
345
  //
@@ -575,7 +579,10 @@ async function handleSlash(task, t) {
575
579
  + ' FETCH: <url> read a page’s text\n'
576
580
  + ' MCP: <url> [| tool | {json}] list or call MCP tools\n'
577
581
  + ' TODO: <lines> visible checklist\n'
578
- + ' SPAWN / SEND / PING / PEEK other bots\n\n'
582
+ + ' SPAWN: <name> | <task> a NEW subagent (names are unique —\n'
583
+ + ' spawning an existing one sends to it)\n'
584
+ + ' SEND: <name> | <msg> more work for an EXISTING subagent\n'
585
+ + ' PING / PEEK reach or inspect another bot\n\n'
579
586
  + 'READ, LS, GLOB, GREP, FETCH, PEEK and MCP run CONCURRENTLY when several\n'
580
587
  + 'appear in one reply — four files cost one round trip, not four.';
581
588
  }
@@ -776,6 +783,26 @@ async function tryDirective(reply, originId) {
776
783
  if (spawn) {
777
784
  const name = spawn[1].trim();
778
785
  const task = spawn[2].trim();
786
+ // NAMES ARE UNIQUE. This used to call newThread() unconditionally, so a
787
+ // model asked to "keep spawning" produced FIFTEEN threads all called
788
+ // tetris-contract, each one a live agent burning paid calls, and the
789
+ // sidebar became an unusable wall of identical rows. A repeat SPAWN is
790
+ // almost always the model re-issuing work for the same worker, not asking
791
+ // for a second identical one — so route it to the existing thread, which
792
+ // is what SEND already does.
793
+ const existing = findByName(name);
794
+ if (existing) {
795
+ runTurn(existing.id, task).catch(() => {});
796
+ return `${name} already exists — sent it the task instead of spawning a duplicate.`;
797
+ }
798
+ // Storm guard. Fire-and-forget spawning is unbounded by construction: each
799
+ // child can spawn, and nothing above it is counting.
800
+ const siblings = [...threads.values()].filter((x) => x.parent === originId).length;
801
+ if (siblings >= SPAWN_MAX_CHILDREN) {
802
+ return `Not spawning "${name}": this thread already has ${siblings} subagents `
803
+ + `(limit ${SPAWN_MAX_CHILDREN}). Reuse one with SEND: <name> | <task> — `
804
+ + `every live subagent costs paid calls.`;
805
+ }
779
806
  const sub = newThread(name, originId);
780
807
  runTurn(sub.id, task).catch(() => {}); // fire and forget — runs independently
781
808
  return `Spawned ${name} — working on it.`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openzoo",
3
- "version": "0.48.8",
3
+ "version": "0.48.9",
4
4
  "description": "Local x402-paying proxy + MCP server for openzoo.fun — point any OpenAI-compatible harness (Cursor, Claude Code, aider, SDKs) at localhost and it pays per call from a local burner wallet. Solana and Base rails live; Robinhood experimental.",
5
5
  "license": "MIT",
6
6
  "type": "module",