graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix: keep worker model pins provider-local
Rach Pradhan6d4feeaa1cf6
diff --git a/README.md b/README.mdindex 0e5f2f31..33dc30f8 100644--- a/README.md+++ b/README.md@@ -752,7 +752,9 @@ GRAFF_SUBAGENT_MODEL=gpt-5.6-terra graff --model gpt-5.6-solThis keeps orchestration/synthesis on Sol and parallel execution on Terrawithout silently crossing credential, billing, or data-boundary domains. Put`ultracode` in a task (or run `/ultracode on`) when you want the root to-actively fan work out; the model split itself does not force delegation.+actively fan work out; the model split itself does not force delegation. If+`/model` later crosses to another provider, children inherit that current root+instead of using the old pin; switching back restores the compatible pin.- Depth capped at one level: subagents don't get the `subagent` tool.- Subagents don't share the root agent's context, so the orchestrator must putdiff --git a/src/subagent.zig b/src/subagent.zigindex bd999e54..f1d52d04 100644--- a/src/subagent.zig+++ b/src/subagent.zig@@ -19,6 +19,7 @@ const agent_mod = @import("agent.zig");const util = @import("util.zig");const repl_glue = @import("repl_glue.zig");const Agent = agent_mod.Agent;+const Provider = @import("provider.zig").Provider;const tools = @import("tools.zig");const ToolCtx = tools.ToolCtx;@@ -149,6 +150,19 @@ fn subagentFailure(gpa: Allocator, sub_id: []const u8, err: anyerror, detail: ?[return .{ .text = text, .is_error = true };}+fn childProvider(root: Provider, pinned: ?Provider) Provider {+ const child = pinned orelse return root;+ return if (std.mem.eql(u8, child.id, root.id)) child else root;+}++test "child model pin cannot cross the current root provider" {+ const codex_root: Provider = .{ .id = "codex", .kind = .responses, .auth = .bearer, .url = "", .api_key = "", .model = "gpt-5.6-sol", .context = 272_000 };+ const terra: Provider = .{ .id = "codex", .kind = .responses, .auth = .bearer, .url = "", .api_key = "", .model = "gpt-5.6-terra", .context = 272_000 };+ const anthropic_root: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "", .model = "claude", .context = 200_000 };+ try std.testing.expectEqualStrings("gpt-5.6-terra", childProvider(codex_root, terra).model);+ try std.testing.expectEqualStrings("claude", childProvider(anthropic_root, terra).model);+}+/// Run one isolated subagent to completion: fresh arena, fresh history,/// same shared http client and the configured child provider (or the root/// provider when no child model is pinned). `sys_override` swaps the@@ -164,7 +178,7 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []constvar arena_state = std.heap.ArenaAllocator.init(gpa);defer arena_state.deinit();const arena = arena_state.allocator();- const child_provider = ctx.subagent_provider orelse ctx.provider;+ const child_provider = childProvider(ctx.provider, ctx.subagent_provider);var agent: Agent = .{.gpa = gpa,@@ -357,7 +371,7 @@ pub fn scoreVariants(const jfuts = arena.alloc(Io.Future(ToolOutput), vn) catch return;for (jfuts, jprompts) |*jf, jp| jf.* = ctx.io.async(judgeTask, .{ ctx, jp });- const pclass = providerClass((ctx.subagent_provider orelse ctx.provider).model);+ const pclass = providerClass(childProvider(ctx.provider, ctx.subagent_provider).model);const run_id: []const u8 = &scoring.g_run_id;for (jfuts, 0..) |*jf, k| {const i = vidx[k];