graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(codex): keep Astra-low on Astra, backtest encrypted reasoning
Rach Pradhan5c22fca0454f
diff --git a/src/agent_request_encrypted_tests.zig b/src/agent_request_encrypted_tests.zignew file mode 100644index 00000000..ca408a27--- /dev/null+++ b/src/agent_request_encrypted_tests.zig@@ -0,0 +1,52 @@+//! Backtest: latest Responses models use the existing encrypted-reasoning+//! path. Astra is not a special store — same `include` + `store:false` ++//! verbatim replay Codex uses. A new GPT-6 slug must not fall off this wire.++const std = @import("std");+const Kind = @import("provider.zig").Provider.Kind;+const testAgentFor = @import("agent_request_body_responses.zig").testAgentFor;+const codegraff = @import("provider_codegraff.zig");++const Case = struct {+ id: []const u8,+ kind: Kind,+ model: []const u8,+};++const latest_responses = [_]Case{+ .{ .id = "codex", .kind = .responses, .model = "gpt-6-astra" },+ .{ .id = "codex", .kind = .responses, .model = "gpt-5.6-sol" },+ .{ .id = "codex", .kind = .responses, .model = "gpt-5.6-luna" },+ .{ .id = "openai", .kind = .responses, .model = "gpt-6-astra" },+ .{ .id = "openai", .kind = .responses, .model = "gpt-5.6-luna" },+ .{ .id = "codegraff", .kind = .responses, .model = "gpt-6-astra" },+ .{ .id = "codegraff", .kind = .responses, .model = "gpt-5.6-sol" },+};++fn withEncryptedHistory(arena: std.mem.Allocator, agent: anytype) !void {+ var item: std.json.ObjectMap = .empty;+ try item.put(arena, "type", .{ .string = "reasoning" });+ try item.put(arena, "id", .{ .string = "rs_astra" });+ try item.put(arena, "encrypted_content", .{ .string = "ENCBLOB" });+ try agent.messages.append(.{ .object = item });+}++test "latest Responses models request and replay encrypted reasoning" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();++ for (latest_responses) |case| {+ if (std.mem.eql(u8, case.id, "codegraff")) {+ try std.testing.expect(codegraff.usesResponses(case.id, case.model));+ }+ var agent = try testAgentFor(a, case.id, case.kind, case.model);+ try withEncryptedHistory(a, &agent);+ const body = try agent.buildBody(null, false, true, true);+ defer std.testing.allocator.free(body);+ try std.testing.expect(std.mem.indexOf(u8, body, "\"include\":[\"reasoning.encrypted_content\"") != null);+ try std.testing.expect(std.mem.indexOf(u8, body, "\"store\":false") != null);+ try std.testing.expect(std.mem.indexOf(u8, body, "\"encrypted_content\":\"ENCBLOB\"") != null);+ try std.testing.expect(std.mem.indexOf(u8, body, "previous_response_id") == null);+ }+}diff --git a/src/effort_route.zig b/src/effort_route.zigindex 2deb8275..74ae2d8d 100644--- a/src/effort_route.zig+++ b/src/effort_route.zig@@ -56,6 +56,7 @@ pub fn shouldRouteLookupLow(_: bool, _: bool, _: []const u8) bool {/// Do not treat this as a 4-tool catalog shrink.pub fn omitsDefaultFlashEffort(model: []const u8) bool {if (std.mem.startsWith(u8, model, "gemini")) return true;+ if (std.mem.indexOf(u8, model, "astra") != null) return true; // Astra-low > Sol-high on SWE-benchreturn std.mem.indexOf(u8, model, "flash") != null;}@@ -111,6 +112,10 @@ test "flash and Gemini map default medium to low; grok and glm-5.3 stay medium"try std.testing.expect(!omitsDefaultFlashEffort("grok-4.6"));try std.testing.expect(!omitsDefaultFlashEffort("glm-5.3"));try std.testing.expect(!omitsDefaultFlashEffort("deepseek-v4-pro"));+ try std.testing.expect(omitsDefaultFlashEffort("gpt-6-astra"));+ try std.testing.expectEqualStrings("low", wireEffort("gpt-6-astra", "medium"));+ try std.testing.expectEqualStrings("high", wireEffort("gpt-5.6-sol", "high"));+ try std.testing.expectEqualStrings("high", wireEffort("gpt-6-astra", "high"));try std.testing.expectEqualStrings("low", wireEffort("glm-5.3-flash", "medium"));try std.testing.expectEqualStrings("high", wireEffort("glm-5.3-flash", "high"));try std.testing.expectEqualStrings("medium", wireEffort("grok-4.6", "medium"));diff --git a/src/fleet.zig b/src/fleet.zigindex a2de9c3e..50c63672 100644--- a/src/fleet.zig+++ b/src/fleet.zig@@ -88,6 +88,7 @@ const builtin_agent_types = [_]AgentType{.desc = "evidence gatherer — reads widely, cites precisely, never edits",.prompt = "You are a research agent. Your job is to READ and REPORT, never to modify anything. Explore the files or sources you are pointed at, follow the references that matter, and produce a tight evidence-backed summary: every claim cites its file:line or source. Separate what you verified from what you infer. End with the 3 facts most load-bearing for the task and 1 open question.",.builtin = true,+ .tier = .small, // luna / flash / sonnet — cheap search seat, same as sol+luna},.{.name = "implementer",@@ -447,6 +448,16 @@ pub fn resolveIsolationFallback(obj: std.json.ObjectMap) bool {return false;}+test "builtin researcher is the small search seat (luna on Codex)" {+ for (builtin_agent_types) |at| {+ if (std.mem.eql(u8, at.name, "researcher")) {+ try std.testing.expectEqual(Tier.small, at.tier.?);+ return;+ }+ }+ try std.testing.expect(false);+}+test "resolveIsolation: explicit field wins, then the named persona's default, then shared_cwd" {_ = agent_file;var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);diff --git a/src/route_policy_tests.zig b/src/route_policy_tests.zigindex 64b33053..f38848f1 100644--- a/src/route_policy_tests.zig+++ b/src/route_policy_tests.zig@@ -128,7 +128,8 @@ test "#372: the shape is read off the phase titles the root model authored" {try std.testing.expectEqualStrings("", policy.roleOf("do the thing", "some-persona"));// tierOf is the ladder inverse the trace needs for an unpinned worker.try std.testing.expectEqual(tier_ladder.Tier.mid, policy.tierOf("codex", "gpt-5.6-terra").?);- try std.testing.expectEqual(tier_ladder.Tier.frontier, policy.tierOf("codex", "gpt-5.6-sol").?);+ try std.testing.expectEqual(tier_ladder.Tier.frontier, policy.tierOf("codex", "gpt-6-astra").?);+ try std.testing.expect(policy.tierOf("codex", "gpt-5.6-sol") == null);try std.testing.expect(policy.tierOf("codex", "claude-opus-4-8") == null); // off this laddertry std.testing.expectEqualStrings("", policy.tierLabelFor("xai", "grok-4.3")); // no ladder at all}diff --git a/src/scoring.zig b/src/scoring.zigindex f7bd9517..f6ada55c 100644--- a/src/scoring.zig+++ b/src/scoring.zig@@ -44,6 +44,7 @@ pub fn providerClass(model: []const u8) []const u8 {.{ .needle = "terra", .tier = "mid" },.{ .needle = "luna", .tier = "small" },.{ .needle = "opus", .tier = "frontier" },+ .{ .needle = "gpt-6", .tier = "frontier" }, // astra and later GPT-6 flagships.{ .needle = "gpt-5", .tier = "frontier" }, // sol and bare gpt-5.x stay frontier.{ .needle = "deepseek-v4", .tier = "frontier" },.{ .needle = "grok-4", .tier = "frontier" },@@ -260,6 +261,7 @@ test "providerClass buckets models by capability tier" {try std.testing.expectEqualStrings("frontier", providerClass("claude-opus-4-8"));try std.testing.expectEqualStrings("frontier", providerClass("gpt-5.5"));try std.testing.expectEqualStrings("frontier", providerClass("gpt-5.6-sol"));+ try std.testing.expectEqualStrings("frontier", providerClass("gpt-6-astra"));try std.testing.expectEqualStrings("mid", providerClass("gpt-5.6-terra")); // rung needle beats "gpt-5"try std.testing.expectEqualStrings("small", providerClass("gpt-5.6-luna"));try std.testing.expectEqualStrings("frontier", providerClass("deepseek-v4-pro"));diff --git a/src/subagent_pin.zig b/src/subagent_pin.zigindex a5bcf9b0..5c9ed919 100644--- a/src/subagent_pin.zig+++ b/src/subagent_pin.zig@@ -314,7 +314,10 @@ fn subscriptionRung(tier: Tier, base: Provider) ?Resolved {const rung = ladder.modelFor(tier) orelse continue;const resolved = selection.modelForProvider(sid, rung) orelse continue;const prov = keys.providerById(sid, resolved) catch continue; // not logged in → not a candidate- const s = bench_priors.scoreFor(sid, resolved) orelse 0;+ // Unbenched compiled frontier (gpt-6-astra) must not lose to a+ // scored older seat at 0. Treat missing as 1.0 only for that rung.+ const s = bench_priors.scoreFor(sid, resolved) orelse+ if (std.mem.eql(u8, resolved, ladder.frontier)) @as(f64, 1.0) else 0;if (best == null or s > best_score) {// source=ladder: it IS a ladder rung, just the subscription's own.best = .{ .provider = prov, .outcome = .sub_routed, .source = .ladder };diff --git a/src/subagent_pin_tests.zig b/src/subagent_pin_tests.zigindex effb59cb..c549717b 100644--- a/src/subagent_pin_tests.zig+++ b/src/subagent_pin_tests.zig@@ -60,6 +60,26 @@ test "persona frontmatter parse: model/tier land on AgentType, a bad tier is drotry std.testing.expect(pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"plain\"}"), true).provider == null);}+test "researcher is the small/luna search seat on Codex, including Astra roots" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const saved = fleet.g_agent_types;+ defer fleet.g_agent_types = saved;+ fleet.g_agent_types = &.{+ .{ .name = "researcher", .desc = "", .prompt = "x", .tier = .small },+ };++ try std.testing.expectEqual(Tier.small, pin_mod.personaPin("researcher").tier.?);+ const sol = pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"researcher\"}"), true);+ try std.testing.expectEqualStrings("gpt-5.6-luna", sol.provider.?.model);++ var astra = codexBase();+ astra.model = "gpt-6-astra";+ const from_astra = pin_mod.forSpawn(astra, obj(a, "{\"agent\":\"researcher\"}"), true);+ try std.testing.expectEqualStrings("gpt-5.6-luna", from_astra.provider.?.model);+}+test "spawn override resolution: exact name, alias, ladder rung, and no-op" {var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);defer arena_state.deinit();@@ -85,8 +105,11 @@ test "spawn override resolution: exact name, alias, ladder rung, and no-op" {try std.testing.expectEqualStrings("gpt-5.6-luna", rung.provider.?.model);try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(base, obj(a, "{\"tier\":\"mid\"}"), true).provider.?.model);- // A pin naming the model the child already has changes nothing, and says so.- const same = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"frontier\"}"), true);+ // Codex frontier is Astra; a Sol child asking for frontier is a real pin.+ const flagship = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"frontier\"}"), true);+ try std.testing.expectEqual(pin_mod.Outcome.pinned, flagship.outcome);+ try std.testing.expectEqualStrings("gpt-6-astra", flagship.provider.?.model);+ const same = pin_mod.forSpawn(base, obj(a, "{\"model\":\"gpt-5.6-sol\"}"), true);try std.testing.expectEqual(pin_mod.Outcome.same, same.outcome);try std.testing.expect(same.provider == null);@@ -296,14 +319,14 @@ test "two logins split the tiers: k3 is mid, luna is the mechanical rung (#471)"// Both plans logged in, metered anthropic root. The three tiers land on// three different paid-for seats, and none of them costs a cent extra:- // frontier -> codex sol (73 beats k3's 68 on the bench sheet)- // mid -> kimi k3 (codex has no mid rung; terra is dominated)+ // frontier -> codex astra (compiled flagship; unbenched beats k3)+ // mid -> kimi k3 (codex mid is terra, dominated on the sheet)// small -> codex luna (kimi declares no small rung, so k3's higher// score cannot swallow the mechanical tier —// code search and greps stay on the cheap seat)const claude: Provider = .{ .id = "anthropic", .kind = .anthropic, .auth = .x_api_key, .url = "", .api_key = "k", .model = "claude-opus-5", .context = 1_000_000 };const want = [_]struct { tier: []const u8, pid: []const u8, model: []const u8 }{- .{ .tier = "frontier", .pid = "codex", .model = "gpt-5.6-sol" },+ .{ .tier = "frontier", .pid = "codex", .model = "gpt-6-astra" },.{ .tier = "mid", .pid = "kimi", .model = "k3" },.{ .tier = "small", .pid = "codex", .model = "gpt-5.6-luna" },};diff --git a/src/subagent_selection.zig b/src/subagent_selection.zigindex d155c612..8559252e 100644--- a/src/subagent_selection.zig+++ b/src/subagent_selection.zig@@ -62,9 +62,16 @@ pub fn modelForProvider(provider_id: []const u8, query: []const u8) ?[]const u8/// one rung. `root.model` must exactly match a rung name (frontier or mid)/// for this provider's ladder — an off-ladder or unrecognized root model/// returns null rather than guessing at the nearest rung.+///+/// GPT-6 Astra stays on Astra. Demoting it onto gpt-5.6-sol/terra is a+/// SWE-bench regression (Astra-low beats Sol-high). Unpinned workers inherit;+/// `tier: small` still seats luna for cheap search. A Sol root still drops+/// one rung onto terra.fn defaultLadderModel(root: provider_mod.Provider) ?[]const u8 {const ladder = tier_ladder.forProvider(root.id) orelse return null;- if (std.mem.eql(u8, root.model, ladder.frontier)) return ladder.mid orelse ladder.small;+ if (std.mem.startsWith(u8, root.model, "gpt-6")) return null;+ if (std.mem.eql(u8, root.model, ladder.frontier) or std.mem.eql(u8, root.model, "gpt-5.6-sol"))+ return ladder.mid orelse ladder.small;if (ladder.mid) |mid| {if (std.mem.eql(u8, root.model, mid)) return ladder.small;}@@ -183,10 +190,12 @@ test "defaultLadderModel: descends one rung per provider, bottom rung inherits"}.p;// codex: sol -> terra -> luna -> (bottom, inherit)try std.testing.expectEqualStrings("gpt-5.6-terra", defaultLadderModel(mk("codex", "gpt-5.6-sol")).?);+ try std.testing.expect(defaultLadderModel(mk("codex", "gpt-6-astra")) == null);try std.testing.expectEqualStrings("gpt-5.6-luna", defaultLadderModel(mk("codex", "gpt-5.6-terra")).?);try std.testing.expect(defaultLadderModel(mk("codex", "gpt-5.6-luna")) == null);// openai: same shape, sibling namestry std.testing.expectEqualStrings("gpt-5.6-terra", defaultLadderModel(mk("openai", "gpt-5.6")).?);+ try std.testing.expect(defaultLadderModel(mk("openai", "gpt-6-astra")) == null);// anthropic: opus-5 -> sonnet-5 -> (bottom). #471 dropped the opus-4-8 and// sonnet-4-6 rungs: every opus generation bills the same $5/$25 per MTok,// so descending within the family is not a cheaper seat at all.@@ -216,6 +225,9 @@ test "default ladder: resolves the mid sibling when no flags are given" {try std.testing.expectEqualStrings("codex", worker.id); // provider-local, unpinnedtry std.testing.expectEqualStrings("gpt-5.6-terra", worker.model);+ const astra_root = try keys.providerById("codex", "gpt-6-astra");+ try std.testing.expect(resolveSubagentProvider(keys, astra_root, null, null, false, false) == null);+const anthropic_root = try keys.providerById("anthropic", "claude-opus-5");const anthropic_worker = resolveSubagentProvider(keys, anthropic_root, null, null, false, false).?;try std.testing.expectEqualStrings("anthropic", anthropic_worker.id);diff --git a/src/subagent_tier_ladder.zig b/src/subagent_tier_ladder.zigindex 250998ad..138726e2 100644--- a/src/subagent_tier_ladder.zig+++ b/src/subagent_tier_ladder.zig@@ -62,7 +62,7 @@ pub const TierLadder = struct {};pub const ladders = [_]TierLadder{- .{ .provider = "codex", .frontier = "gpt-5.6-sol", .mid = "gpt-5.6-terra", .small = "gpt-5.6-luna" },+ .{ .provider = "codex", .frontier = "gpt-6-astra", .mid = "gpt-5.6-terra", .small = "gpt-5.6-luna" },.{ .provider = "openai", .frontier = "gpt-5.6", .mid = "gpt-5.6-terra", .small = "gpt-5.6-luna" },// #471: opus-5 and sonnet-5 are the current lineup, and the rungs below// frontier must be cheaper SEATS. Every opus generation bills the same@@ -161,7 +161,7 @@ fn inShippedTable(provider_id: []const u8, model: []const u8) bool {}test "forProvider: known providers found, others null" {- try std.testing.expectEqualStrings("gpt-5.6-sol", forProvider("codex").?.frontier);+ try std.testing.expectEqualStrings("gpt-6-astra", forProvider("codex").?.frontier);try std.testing.expectEqualStrings("deepseek-v4-flash", forProvider("deepseek").?.small.?);try std.testing.expectEqualStrings("deepseek-v4-flash", forProvider("codegraff").?.small.?);try std.testing.expect(forProvider("xai") == null);@@ -179,7 +179,7 @@ test "Tier.parse/modelFor: the rung vocabulary #292 pins against (#291 names)" {try std.testing.expectEqualStrings("small", Tier.small.label());const codex = forProvider("codex").?;- try std.testing.expectEqualStrings("gpt-5.6-sol", codex.modelFor(.frontier).?);+ try std.testing.expectEqualStrings("gpt-6-astra", codex.modelFor(.frontier).?);try std.testing.expectEqualStrings("gpt-5.6-terra", codex.modelFor(.mid).?);try std.testing.expectEqualStrings("gpt-5.6-luna", codex.modelFor(.small).?);// A family with no such rung answers null rather than the nearest rung.diff --git a/src/test_hooks.zig b/src/test_hooks.zigindex 26c162f5..5f74ceab 100644--- a/src/test_hooks.zig+++ b/src/test_hooks.zig@@ -156,6 +156,7 @@ const tool_surface = @import("tool_surface.zig");const agent_catalog = @import("agent_catalog.zig");const session_connect_tests = @import("session_connect_tests.zig");const effort_route = @import("effort_route.zig");+const agent_request_encrypted_tests = @import("agent_request_encrypted_tests.zig");// #416: two-phase MCP tool exposure. schema.zig/exec.zig reach the gate, but// its tests live in a sibling file that nothing in production imports.