Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Merge fix/U3-prev-phase-budget

Rach Pradhan13c729591b3d
diff --cc src/workflow.zig
index 03ed11e1,b2575445..dc385554
--- a/src/workflow.zig
+++ b/src/workflow.zig
@@@ -446,8 -391,11 +473,13 @@@ pub fn execWorkflow(ctx: ToolCtx, input
// open (it submits niche=""). Gated on the fleet — no judge cost otherwise.
scoreVariants(ctx, arena, title, prompts, raws, overrides, niches, outputs);
- // U3: divide the {{prev}} budget across THIS phase's own task count so
- // a wide phase's total contribution to the next phase's prompt stays
- // near phase_prev_budget instead of growing with tasks.len — see the
+ tallies[phase_no - 1] = .{ .phase_no = phase_no, .total_phases = phases.len, .title = title, .ok = tasks.len - phase_failed, .total = tasks.len, .retried = nf };
+
++ // Divide the {{prev}} budget across THIS phase's own task count so a
++ // wide phase's total contribution to the next phase's prompt stays near
++ // phase_prev_budget instead of growing with tasks.len — see the
+ // phase_prev_budget doc comment above for the quadratic-cost story.
+ const per_task_cap = phaseTaskCap(tasks.len);
var aw: Io.Writer.Allocating = .init(arena);
for (labels, outputs) |label, out| {
if (out.is_error) {
@@@ -460,12 -408,10 +492,12 @@@
}
prev_results = std.mem.trimEnd(u8, aw.writer.buffered(), "\n");
}
- return .{ .text = try gpa.dupe(u8, prev_results) };
+ const manifest = try buildManifest(arena, tallies);
+ const final_text = try std.fmt.allocPrint(arena, "{s}\n\n{s}", .{ prev_results, manifest });
+ return .{ .text = try gpa.dupe(u8, final_text) };
}
- test "cappedPrevBody bounds a wide phase output, keeps head + inspect tail (#4)" {
+ test "cappedPrevBody bounds a wide phase output, keeps head + inspect tail at several caps (#4/U3)" {
var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena_state.deinit();
const a = arena_state.allocator();