z0gcode 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -90,7 +90,7 @@ z0g serve --mcp # expose z0gcode's 0G t
90
90
  - **Project context**: `AGENTS.md` (and `.z0g/context.md`) are auto-loaded into the agent's system prompt on every run, so it follows your conventions and uses your real build/test/run commands. `z0g init` (or `/init`) analyzes the repo and writes an accurate `AGENTS.md` for you.
91
91
  - **Checkpoints and undo**: every file edit is logged with its before/after content per turn, so `z0g undo` (or `/undo`) reverts the last turn's changes (restoring files, deleting ones it created); `z0g checkpoints` lists what you can step back through.
92
92
  - **Custom commands and hooks**: drop `.z0g/commands/<name>.md` to add a `/<name>` slash command (the file is a prompt template; `$ARGUMENTS` is substituted, optional `description:` frontmatter, Tab-completed and listed by `/commands`). Define lifecycle hooks in `.z0g/hooks.json` (`preRun` / `postRun` shell commands, e.g. run your formatter or tests after each turn); hooks run shell, so they only fire with `--auto`.
93
- - Reliability on a decentralized backend: app-level multi-model fallback, retry and backoff, tool-JSON repair, a loop breaker (stops on repeated identical calls, or the same tool result with no progress, so it hands control back instead of spinning), and model escalation (when a tool fails repeatedly it moves to a stronger fallback for the rest of the turn; on by default after 3 failures, toggle with `/escalate on|off` or `--no-escalate`).
93
+ - Reliability on a decentralized backend: app-level multi-model fallback, retry and backoff, tool-JSON repair, a loop breaker (on repeated identical calls, or the same tool result with no progress, it first escalates to a stronger model to try to get unstuck and only then hands control back, instead of spinning), and model escalation (when a tool fails repeatedly it moves to a stronger fallback for the rest of the turn; on by default after 3 failures, toggle with `/escalate on|off` or `--no-escalate`).
94
94
  - **Parallel subagents**: `spawn_subagents` fans out independent, read-only subtasks (review many files, research, audit, map a codebase) as isolated agents running in parallel, capped by `ZOG_MAX_PARALLEL`. The parent synthesizes the results and each subagent's transcript is saved. With 0G's cheap inference, fanning out to many agents costs cents: massively parallel agents at 0G prices. On by default; toggle with `/subagents on|off` or `--no-subagents`.
95
95
  - **Parallel write subagents**: with `--auto` in a git repo, `spawn_write_subagents` fans out subtasks that WRITE code, each in its own isolated **git worktree**, then merges every diff back into the working tree. Disjoint file sets merge automatically; overlapping edits are reported and skipped (never half-applied), and the merged changes are checkpointed so `z0g undo` reverts them. Verified end-to-end on 0G.
96
96
 
package/bin/z0g.mjs CHANGED
@@ -1045,7 +1045,7 @@ async function main() {
1045
1045
  if (flags.version) {
1046
1046
  let v = "";
1047
1047
  try { v = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version; } catch {}
1048
- console.log("z0gcode " + (v || "0.3.1"));
1048
+ console.log("z0gcode " + (v || "0.3.2"));
1049
1049
  return;
1050
1050
  }
1051
1051
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z0gcode",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A terminal coding agent whose brain runs on 0G Compute: private, verifiable AI with on-chain provenance.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/agent.mjs CHANGED
@@ -92,6 +92,7 @@ export async function runAgent({ client, task, cwd, sessionDir, allowBash, prefe
92
92
 
93
93
  const recent = []; // circuit breaker on repeated identical tool calls
94
94
  const results = []; // no-progress breaker: repeated identical tool RESULTS
95
+ let loopEscalated = false; // escalate once on a spin before giving up
95
96
  const failCounts = {}; // per-tool failure counter, drives model escalation
96
97
  const escalateOn = preferredEscalate !== undefined ? preferredEscalate : CONFIG.escalate;
97
98
  const escalateAfter = CONFIG.escalateAfter;
@@ -301,7 +302,15 @@ export async function runAgent({ client, task, cwd, sessionDir, allowBash, prefe
301
302
  const rkey = `${name}|${res.summary || ""}|${String(res.content ?? "").slice(0, 300)}`;
302
303
  results.push(rkey);
303
304
  if (results.length > 8) results.shift();
304
- if (results.filter((k) => k === rkey).length >= 3) stuck = true;
305
+ const repeat = results.filter((k) => k === rkey).length;
306
+ // Spinning on the same result: it is usually a model limitation, so first
307
+ // escalate to a stronger model (and stay on it) to give it a chance to get
308
+ // unstuck; only give up and hand control back if it still makes no progress.
309
+ if (repeat === 2 && escalateOn && !loopEscalated && activeModel === models[0]) {
310
+ escalate = true; loopEscalated = true;
311
+ if (!q) ui.info("spinning on the same result: trying a stronger model");
312
+ }
313
+ if (repeat >= (escalateOn ? 4 : 3)) stuck = true;
305
314
  }
306
315
 
307
316
  if (stuck) {