graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(budget): default model-call budget to unlimited, raise concurrency to 8
Rach Pradhanedf945fc914d
diff --git a/docs/releases/v0.0.212.md b/docs/releases/v0.0.212.mdnew file mode 100644index 00000000..5f52e62d--- /dev/null+++ b/docs/releases/v0.0.212.md@@ -0,0 +1,34 @@+# Unlimited model-call budget by default, wider default concurrency++v0.0.212 removes a run-wide ceiling that could halt an otherwise healthy+session. It is a small, compatible hotfix on top of v0.0.211.++## Run budget no longer wedges a session++- The invocation-wide model-call budget defaulted to 256 calls and never reset+ for the life of the process. A single workflow fan-out could reach that+ ceiling, after which every later turn failed at admission with+ `RunBudgetExhausted` before it ever reached a model.+- The model-call count ceiling now defaults to unlimited. The Workflow layer+ keeps its own 1000-agent runaway backstop and the recursion-depth guard is+ unchanged, so the safety that actually prevents runaway loops stays in place.+- An explicit `--max-model-calls N` or `GRAFF_MAX_MODEL_CALLS=N` with a positive+ N still enforces a hard ceiling for anyone who wants one. A value of 0 now+ means unlimited.+- Default in-flight model-call concurrency rises from 4 to 8, so parallel+ subagents and workflow stages admit more work at once.++## Validation and distribution++- The full Zig test suite, including a new test that proves an unlimited budget+ never exhausts across a thousand admissions, passes. Formatting and build+ checks pass.+- Both macOS binaries are Developer ID signed and submitted to Apple's+ notarization service before this draft is published.+- Every published archive is covered by `SHA256SUMS`.++```sh+curl -fsSL https://raw.githubusercontent.com/justrach/codegraff/main/install.sh | sh+```++**Full changelog:** https://github.com/justrach/codegraff/compare/v0.0.211...v0.0.212diff --git a/src/main.zig b/src/main.zigindex b3bf8bd9..ceec6047 100644--- a/src/main.zig+++ b/src/main.zig@@ -61,7 +61,7 @@ pub var g_force_drop_once: bool = false; // #132/#133 test seam (GRAFF_FORCE_DROpub var g_force_stall_always: bool = false; // #56 test seam (GRAFF_FORCE_STALL_ALWAYS=1): EVERY live attempt stalls, so the reconnect budget exhausts and the turn ends as a stall — exercises the give-up path offlinepub var g_force_drop_always: bool = false; // #56 test seam (GRAFF_FORCE_DROP_ALWAYS=1): EVERY live attempt dropspub var max_tool_calls: ?u64 = null; // --max-tool-calls: hard per-turn root tool budget-pub var max_model_calls: u64 = run_budget_mod.default_max_model_calls; // invocation-wide, shared by root/children/title/judges+pub var max_model_calls: u64 = run_budget_mod.default_max_model_calls; // invocation-wide, shared by root/children/title/judges; 0 = unlimited (default)pub var dedupe_tool_calls = false; // --dedupe-tool-calls: reject duplicate root calls in a turnpub var plan_mode = false; // /plan: read-only — mutating tools are denied, the model proposespub var unattended = false; // -p one-shot: no human to prompt; unapproved tool calls are denieddiff --git a/src/run_budget.zig b/src/run_budget.zigindex 61ffdbe5..b7f36aaa 100644--- a/src/run_budget.zig+++ b/src/run_budget.zig@@ -2,13 +2,21 @@//! subagents, workflow retries, judges, compaction, and AI title generation.//! Every Agent borrows the same instance; atomics make admission safe across//! the Io pool without serializing network calls behind a mutex.+//!+//! The model-call *count* ceiling defaults to unlimited (`max_model_calls == 0`).+//! It is a process-lifetime counter that never resets, so any finite cap wedges+//! every later turn once a workflow fan-out hits it — and the Workflow layer+//! already carries its own 1000-agent runaway backstop. Depth and concurrency+//! stay bounded: those cap recursion and parallel connections, not whole turns.const std = @import("std");const Io = std.Io;-pub const default_max_concurrency: u32 = 4;+pub const default_max_concurrency: u32 = 8;pub const default_max_depth: u8 = 1;-pub const default_max_model_calls: u64 = 256;+/// 0 = unlimited (default). Set a positive --max-model-calls / GRAFF_MAX_MODEL_CALLS+/// only when you deliberately want a hard ceiling on model calls for the whole run.+pub const default_max_model_calls: u64 = 0;pub const CallKind = enum {root,@@ -59,6 +67,8 @@ pub const RunBudget = struct {}fn reserveCall(self: *RunBudget) !u64 {+ // 0 = unlimited: keep counting for used()/telemetry, but never refuse.+ if (self.max_model_calls == 0) return self.model_calls.fetchAdd(1, .acq_rel) + 1;var current = self.model_calls.load(.acquire);while (current < self.max_model_calls) {if (self.model_calls.cmpxchgWeak(current, current + 1, .acq_rel, .acquire)) |observed| {@@ -89,6 +99,7 @@ pub const RunBudget = struct {}pub fn remaining(self: *const RunBudget) u64 {+ if (self.max_model_calls == 0) return std.math.maxInt(u64); // 0 = unlimitedreturn self.max_model_calls -| self.used();}};@@ -108,3 +119,14 @@ test "RunBudget enforces depth, call ceiling, and releases concurrency" {try std.testing.expectEqual(@as(u64, 0), budget.remaining());try std.testing.expectEqual(@as(u32, 1), budget.peak_active.load(.acquire));}++test "RunBudget with max_model_calls = 0 is unlimited and never exhausts" {+ var budget: RunBudget = .{ .max_model_calls = 0, .max_concurrency = 1, .max_depth = 1 };+ var i: u64 = 0;+ while (i < 1000) : (i += 1) {+ var permit = try budget.acquire(std.testing.io, 0, .root);+ permit.release();+ }+ try std.testing.expectEqual(@as(u64, 1000), budget.used());+ try std.testing.expectEqual(std.math.maxInt(u64), budget.remaining());+}