graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Expose session effort configuration over ACP
Rach Pradhana75e1a171311
diff --git a/build.zig b/build.zigindex c5e8dc9c..65629a2b 100644--- a/build.zig+++ b/build.zig@@ -137,6 +137,9 @@ pub fn build(b: *std.Build) void {const acp_startup_test = b.addSystemCommand(&.{ "python3", "scripts/test-acp-startup.py" });acp_startup_test.addArtifactArg(exe);test_step.dependOn(&acp_startup_test.step);+ const acp_effort_test = b.addSystemCommand(&.{ "python3", "scripts/test-acp-effort-config.py" });+ acp_effort_test.addArtifactArg(exe);+ test_step.dependOn(&acp_effort_test.step);const workflow_isolation_test = b.addSystemCommand(&.{ "python3", "scripts/test-workflow-isolation.py" });workflow_isolation_test.addArtifactArg(exe);test_step.dependOn(&workflow_isolation_test.step);diff --git a/docs/adr/0191-acp-effort-is-session-configuration.md b/docs/adr/0191-acp-effort-is-session-configuration.mdnew file mode 100644index 00000000..11745a18--- /dev/null+++ b/docs/adr/0191-acp-effort-is-session-configuration.md@@ -0,0 +1,26 @@+# 0191. ACP effort is session configuration++Status: accepted 2026-09-23++## Context++ACP clients need a standard way to show and change the active thought level. A+slash command alone is invisible to generic clients, and a picker must not+offer effort values the current model rejects.++## Decision++`session/new` and `session/load` return a `thought_level` select option derived+from the active model's effort allowlist. `session/set_config_option` validates+the session, option and value, then changes the same state as `/effort` and+returns the complete option list. Agent-originated `/effort` or `/model`+changes publish a complete `config_option_update` when the option state+changes. A setter received during a prompt stays in the ordinary request queue+and applies to the next turn; it does not steer or cancel the running prompt.++## Consequences++Generic ACP clients and existing slash-command clients share one effort state.+An explicit selection can change the next model request's cached prefix, while+the active request remains stable. Models without effort support expose no+thought-level option.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 41da4957..25e0f601 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -215,6 +215,7 @@ record only when you need the evidence or the edge cases.| [0187](0187-optional-judgments-preserve-usage-uncertainty.md) | Optional judgments use an independent gateway login; tokens and unsettled cost remain distinct in CLI and ACP usage. || [0188](0188-streamed-tool-calls-retain-identity.md) | Streamed tool calls use explicit IDs; reused indexes keep incomplete predecessors invalid, and prose is not execution evidence. || [0189](0189-bounded-buffered-http2-posts.md) | Buffered HTTP/2 posts cap body growth, use exclusive pooled leases with durable transport allocation, join deadlines, and never replay ambiguous sends. |+| [0191](0191-acp-effort-is-session-configuration.md) | ACP thought-level options follow the active model and share `/effort` state; changes received during a turn apply after that turn. |## When to write onediff --git a/scripts/test-acp-effort-config.py b/scripts/test-acp-effort-config.pynew file mode 100644index 00000000..06a618ff--- /dev/null+++ b/scripts/test-acp-effort-config.py@@ -0,0 +1,76 @@+#!/usr/bin/env python3+"""Offline ACP thought-level option and next-request wire regression."""+import importlib.util+import sys+import tempfile+from pathlib import Path++REPO = Path(__file__).resolve().parents[1]+loader = importlib.util.spec_from_file_location("acp_load_test", REPO / "scripts/test-acp-session-load.py")+load_test = importlib.util.module_from_spec(loader)+loader.loader.exec_module(load_test)+Acp = load_test.Acp+ScriptedModel = load_test.ScriptedModel+++def option(response):+ options = response["result"]["configOptions"]+ assert len(options) == 1, options+ selected = options[0]+ assert selected["id"] == selected["category"] == "thought_level", selected+ assert selected["type"] == "select", selected+ assert selected["name"] == "Thought Level", selected+ return selected+++def run(binary):+ with tempfile.TemporaryDirectory(prefix="graff-acp-effort-") as temporary:+ cwd = Path(temporary)+ home = cwd / "home"+ home.mkdir()+ model = ScriptedModel([{"text": "first"}, {"text": "second"}])+ port = model.start(0)+ acp = Acp(binary, cwd, home, port)+ try:+ acp.request("initialize", {"protocolVersion": 1})+ created = acp.request("session/new", {"cwd": str(cwd), "mcpServers": []})+ sid = created["result"]["sessionId"]+ initial = option(created)+ assert initial["currentValue"] == "medium", initial+ assert [item["value"] for item in initial["options"]] == ["low", "medium", "high", "xhigh", "max", "ultra"]+ for params in (+ {"sessionId": "wrong", "configId": "thought_level", "value": "high"},+ {"sessionId": sid, "configId": "unknown", "value": "high"},+ {"sessionId": sid, "configId": "thought_level", "value": "invalid"},+ {"sessionId": sid, "configId": "thought_level", "value": True},+ ):+ rejected = acp.request("session/set_config_option", params)+ assert rejected["error"]["code"] == -32602, rejected+ assert not model.requests, "a configuration request started inference"+ selected = acp.request("session/set_config_option", {"sessionId": sid, "configId": "thought_level", "value": "high"})+ assert option(selected)["currentValue"] == "high", selected+ assert not model.requests, "selecting effort started inference"+ prompt = lambda text: {"sessionId": sid, "prompt": [{"type": "text", "text": text}]}+ first = acp.request("session/prompt", prompt("Say first."), 35)+ assert first["result"]["stopReason"] == "end_turn", first+ assert model.requests[0]["reasoning"]["effort"] == "high", model.requests[0]+ before = len(model.requests)+ start = len(acp.events)+ changed = acp.request("session/prompt", prompt("/effort low"))+ assert changed["result"]["stopReason"] == "end_turn", changed+ assert len(model.requests) == before, "slash command started inference"+ updates = [event["params"]["update"] for event in acp.events[start:] if event.get("method") == "session/update"]+ changed_options = [update for update in updates if update.get("sessionUpdate") == "config_option_update"]+ assert len(changed_options) == 1, updates+ assert option({"result": changed_options[0]})["currentValue"] == "low", changed_options+ second = acp.request("session/prompt", prompt("Say second."), 35)+ assert second["result"]["stopReason"] == "end_turn", second+ assert model.requests[1]["reasoning"]["effort"] == "low", model.requests[1]+ finally:+ acp.close()+ model.stop()+ print("ACP thought-level config, notifications and next-request effort: ok")+++if __name__ == "__main__":+ run(Path(sys.argv[1] if len(sys.argv) > 1 else REPO / "zig-out/bin/graff").resolve())diff --git a/scripts/test-acp-session-load.py b/scripts/test-acp-session-load.pyindex 8e4d4c17..4023e739 100644--- a/scripts/test-acp-session-load.py+++ b/scripts/test-acp-session-load.py@@ -126,6 +126,8 @@ def run(binary):assert init["result"]["agentCapabilities"]["loadSession"] is Truesid = a.request("session/new", {"cwd": str(cwd), "mcpServers": []})["result"]["sessionId"]assert "/" not in sid and "\\" not in sid+ changed = a.request("session/set_config_option", {"sessionId": sid, "configId": "thought_level", "value": "high"})+ assert changed["result"]["configOptions"][0]["currentValue"] == "high"duplicate = a.request("session/new", {"cwd": str(cwd), "mcpServers": []})assert duplicate["error"]["code"] == -32000turn = a.request("session/prompt", {"sessionId": sid, "prompt": [{"type": "text", "text": "Original human request."}]}, 35)@@ -155,6 +157,8 @@ def run(binary):created = b.request("session/new", {"cwd": str(cwd), "mcpServers": []})["result"]fresh = created["sessionId"]assert fresh != sid+ lowered = b.request("session/set_config_option", {"sessionId": fresh, "configId": "thought_level", "value": "low"})+ assert lowered["result"]["configOptions"][0]["currentValue"] == "low"bad = b.request("session/load", {"sessionId": "../escape", "cwd": str(cwd), "mcpServers": []})assert bad["error"]["code"] == -32602missing = b.request("session/load", {"sessionId": "missing", "cwd": str(cwd), "mcpServers": []})@@ -167,7 +171,12 @@ def run(binary):assert wrong["error"]["code"] == -32602before = len(b.events)loaded = b.request("session/load", {"sessionId": sid, "cwd": str(cwd), "mcpServers": []})- assert loaded.get("result") == {}, (created, loaded)+ created_config = created["configOptions"]+ loaded_config = loaded["result"]["configOptions"]+ assert len(created_config) == len(loaded_config) == 1, (created, loaded)+ assert created_config[0]["category"] == loaded_config[0]["category"] == "thought_level"+ assert created_config[0]["currentValue"] == "high", created_config+ assert loaded_config[0]["currentValue"] == "low", loaded_configduplicate_after_load = b.request("session/new", {"cwd": str(cwd), "mcpServers": []})assert duplicate_after_load["error"]["code"] == -32000replay = b.events[before:]@@ -181,6 +190,7 @@ def run(binary):assert stale_session["error"]["code"] == -32602continued = b.request("session/prompt", {"sessionId": sid, "prompt": [{"type": "text", "text": "Continue with original context."}]}, 35)assert continued["result"]["stopReason"] == "end_turn"+ assert next_model.requests[0]["reasoning"]["effort"] == "low"assert next_model.new_handle != oldassert "Original human request." in json.dumps(next_model.requests[0])assert "Original assistant answer." in json.dumps(next_model.requests[0])diff --git a/src/acp_config.zig b/src/acp_config.zignew file mode 100644index 00000000..5babfa48--- /dev/null+++ b/src/acp_config.zig@@ -0,0 +1,60 @@+//! The live ACP thought-level selector shares the root effort state with /effort.+const std = @import("std");+const Allocator = std.mem.Allocator;+const engine = @import("acp_engine.zig");+const er = @import("effort_route.zig");+const LiveTurn = @import("acp_live_turn.zig").LiveTurn;+const ReasoningEffort = @import("main.zig").ReasoningEffort;++fn label(tag: []const u8) []const u8 {+ if (std.mem.eql(u8, tag, "low")) return "Low";+ if (std.mem.eql(u8, tag, "medium")) return "Medium";+ if (std.mem.eql(u8, tag, "high")) return "High";+ if (std.mem.eql(u8, tag, "xhigh")) return "Extra High";+ if (std.mem.eql(u8, tag, "max")) return "Max";+ return "Ultra";+}++pub fn option(ctx: *anyopaque, arena: Allocator) anyerror!?engine.ConfigOption {+ const live: *LiveTurn = @ptrCast(@alignCast(ctx));+ const root = live.root;+ if (!root.effortApplies()) return null;+ const levels = er.levels(root.provider.id, root.provider.model);+ const values = try arena.alloc(engine.ConfigValue, levels.len);+ for (levels, values) |tag, *value| value.* = .{ .value = tag, .name = label(tag) };+ const normalized = er.normalize(root.provider.id, root.provider.model, @tagName(root.reasoning));+ return .{ .currentValue = if (er.allows(root.provider.id, root.provider.model, normalized)) normalized else "high", .options = values };+}++pub fn set(ctx: *anyopaque, value: []const u8) anyerror!bool {+ const live: *LiveTurn = @ptrCast(@alignCast(ctx));+ const root = live.root;+ if (!root.effortApplies() or !er.allows(root.provider.id, root.provider.model, value)) return false;+ root.reasoning = std.meta.stringToEnum(ReasoningEffort, value) orelse return false;+ _ = @import("repl_glue.zig").saveThinkingSettings(root.io, root.gpa, root.reasoning, root.fast, root.ultracode_mode, root.show_thinking, root.ai_title);+ return true;+}++test "thought-level options follow the active model allowlist and normalized current value" {+ var state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer state.deinit();+ const arena = state.allocator();+ var root = try @import("agent_request_body_responses.zig").testAgentFor(arena, "openai", .responses, "gpt-6-astra");+ var keys: @import("provider.zig").Keys = .{ .values = @splat(null) };+ var live: LiveTurn = .{ .root = &root, .keys = &keys, .out = undefined };+ root.reasoning = .max;+ const broad = (try option(&live, arena)).?;+ try std.testing.expectEqualStrings("ultra", broad.currentValue);+ try std.testing.expectEqual(@as(usize, 5), broad.options.len);+ try std.testing.expectEqualStrings("ultra", broad.options[4].value);+ root.provider.id = "xai";+ root.provider.model = "grok-4.6";+ const narrow = (try option(&live, arena)).?;+ try std.testing.expectEqualStrings("high", narrow.currentValue);+ try std.testing.expectEqual(@as(usize, 4), narrow.options.len);+ try std.testing.expectEqualStrings("xhigh", narrow.options[3].value);+ root.provider.id = "anthropic";+ root.provider.kind = .anthropic;+ root.provider.model = "claude-opus-4-8";+ try std.testing.expect((try option(&live, arena)) == null);+}diff --git a/src/acp_engine.zig b/src/acp_engine.zigindex f696a374..8a0ba669 100644--- a/src/acp_engine.zig+++ b/src/acp_engine.zig@@ -41,6 +41,17 @@ pub const MeterFn = *const fn (ctx: *anyopaque) Meter;/// Vendor-method escape hatch: gets every request the core loop does not/// claim; returns true when it answered (false falls through to -32601).pub const ExtraFn = *const fn (ctx: *anyopaque, arena: Allocator, w: *Io.Writer, req: proto.Request) anyerror!bool;+pub const ConfigValue = struct { value: []const u8, name: []const u8 };+pub const ConfigOption = struct {+ id: []const u8 = "thought_level",+ name: []const u8 = "Thought Level",+ category: []const u8 = "thought_level",+ type: []const u8 = "select",+ currentValue: []const u8,+ options: []const ConfigValue,+};+pub const ConfigFn = *const fn (ctx: *anyopaque, arena: Allocator) anyerror!?ConfigOption;+pub const SetConfigFn = *const fn (ctx: *anyopaque, value: []const u8) anyerror!bool;pub const Dispatch = struct {turn: TurnFn,@@ -56,11 +67,40 @@ pub const Dispatch = struct {durable_session_id: ?[]const u8 = null,meter: ?MeterFn = null,extra: ?ExtraFn = null,+ config: ?ConfigFn = null,+ set_config: ?SetConfigFn = null,error_message: ?*const fn (ctx: *anyopaque, err: anyerror) []const u8 = null,/// Isolated checkout after session start (`g_cwd_display`). Empty omits the field.cwd: []const u8 = "",};+pub fn configOptions(d: *Dispatch, arena: Allocator) ![]const ConfigOption {+ const config = d.config orelse return &.{};+ const option = try config(d.ctx, arena) orelse return &.{};+ const items = try arena.alloc(ConfigOption, 1);+ items[0] = option;+ return items;+}++fn sameConfig(before: []const ConfigOption, after: []const ConfigOption) bool {+ if (before.len != after.len) return false;+ for (before, after) |a, b| {+ if (!std.mem.eql(u8, a.currentValue, b.currentValue) or a.options.len != b.options.len) return false;+ for (a.options, b.options) |av, bv| if (!std.mem.eql(u8, av.value, bv.value)) return false;+ }+ return true;+}++fn emitConfigChange(d: *Dispatch, arena: Allocator, w: *Io.Writer, sid: []const u8, before: []const ConfigOption) !void {+ if (d.config == null) return;+ const after = try configOptions(d, arena);+ if (sameConfig(before, after)) return;+ try proto.writeNotification(w, "session/update", .{ .sessionId = sid, .update = .{+ .sessionUpdate = "config_option_update",+ .configOptions = after,+ } });+}+fn respond(w: *Io.Writer, req: proto.Request, result: anytype) !void {if (req.id == null) return;try writeResult(w, req.id, result);@@ -102,18 +142,27 @@ fn promptTurn(d: *Dispatch, arena: Allocator, w: *Io.Writer, req: proto.Request)break :blk d.session_id orelse "";};if (d.bind_session) |bind| bind(d.ctx, sid);+ const config_before = configOptions(d, arena) catch |err| return turnError(d, w, req, err);const text = try flattenPrompt(arena, if (obj) |o| o.get("prompt") else null);if (d.slash) |slash| {- const reply = slash(d.ctx, arena, text) catch |err| return turnError(d, w, req, err);+ const reply = slash(d.ctx, arena, text) catch |err| {+ emitConfigChange(d, arena, w, sid, config_before) catch |config_err| return turnError(d, w, req, config_err);+ return turnError(d, w, req, err);+ };if (reply) |plain| {if (plain.len > 0) try writeSessionUpdate(w, sid, plain);+ emitConfigChange(d, arena, w, sid, config_before) catch |config_err| return turnError(d, w, req, config_err);try emitMeter(d, w, sid);return respond(w, req, .{ .stopReason = "end_turn" });}}if (d.after_user) |after| after(d.ctx, arena, text);- const final = d.turn(d.ctx, arena, text) catch |err| return turnError(d, w, req, err);+ const final = d.turn(d.ctx, arena, text) catch |err| {+ emitConfigChange(d, arena, w, sid, config_before) catch |config_err| return turnError(d, w, req, config_err);+ return turnError(d, w, req, err);+ };if (final.len > 0) try writeSessionUpdate(w, sid, final);+ emitConfigChange(d, arena, w, sid, config_before) catch |config_err| return turnError(d, w, req, config_err);try emitMeter(d, w, sid);const extra = if (extra_cancelled) |f| f() else false;const stop: []const u8 = if (cancel_flag.load(.acquire) or extra) "cancelled" else "end_turn";@@ -188,14 +237,22 @@ pub fn handleLine(d: *Dispatch, arena: Allocator, w: *Io.Writer, line: []const ureturn respondError(w, req, -32000, "This ACP process already owns a session");d.created += 1;d.session_id = d.durable_session_id orelse try std.fmt.allocPrint(arena, "acp-{x}-{d}", .{ d.seed, d.created });- if (d.cwd.len > 0)+ if (d.config != null) {+ const options = configOptions(d, arena) catch |err| return respondError(w, req, err_internal, @errorName(err));+ if (d.cwd.len > 0)+ try respond(w, req, .{ .sessionId = d.session_id.?, .cwd = d.cwd, .configOptions = options })+ else+ try respond(w, req, .{ .sessionId = d.session_id.?, .configOptions = options });+ } else if (d.cwd.len > 0)try respond(w, req, .{ .sessionId = d.session_id.?, .cwd = d.cwd })elsetry respond(w, req, .{ .sessionId = d.session_id.? });try proto.writeAvailableCommands(w, d.session_id.?, proto.slashCommands());return;}- if (d.load_session != null and (std.mem.eql(u8, req.method, "session/prompt") or std.mem.eql(u8, req.method, "session/cancel"))) {+ if ((d.load_session != null and (std.mem.eql(u8, req.method, "session/prompt") or std.mem.eql(u8, req.method, "session/cancel"))) or+ (d.set_config != null and std.mem.eql(u8, req.method, "session/set_config_option")))+ {const params = req.params orelse return respondError(w, req, -32602, "Invalid session ID");if (params != .object) return respondError(w, req, -32602, "Invalid session ID");const sid = util.strFieldObj(params.object, "sessionId") orelse return respondError(w, req, -32602, "Invalid session ID");@@ -211,6 +268,18 @@ pub fn handleLine(d: *Dispatch, arena: Allocator, w: *Io.Writer, line: []const uif (std.mem.eql(u8, req.method, "session/load")) {if (d.load_session) |load| return load(d.ctx, arena, w, req);}+ if (std.mem.eql(u8, req.method, "session/set_config_option") and d.set_config != null) {+ const params = req.params orelse return respondError(w, req, -32602, "Invalid configuration option");+ if (params != .object) return respondError(w, req, -32602, "Invalid configuration option");+ const id = util.strFieldObj(params.object, "configId") orelse return respondError(w, req, -32602, "Invalid configuration option");+ const value = util.strFieldObj(params.object, "value") orelse return respondError(w, req, -32602, "Invalid configuration value");+ if (!std.mem.eql(u8, id, "thought_level"))+ return respondError(w, req, -32602, "Invalid configuration value");+ const accepted = d.set_config.?(d.ctx, value) catch |err| return respondError(w, req, err_internal, @errorName(err));+ if (!accepted) return respondError(w, req, -32602, "Invalid configuration value");+ const options = configOptions(d, arena) catch |err| return respondError(w, req, err_internal, @errorName(err));+ return respond(w, req, .{ .configOptions = options });+ }if (std.mem.eql(u8, req.method, "session/prompt")) return promptTurn(d, arena, w, req);if (d.extra) |extra| if (try extra(d.ctx, arena, w, req)) return;if (req.id == null) return;@@ -275,6 +344,87 @@ test "in-process embed can still create a second session" {try std.testing.expectEqualStrings("acp-22-2", d.session_id.?);}+test "ACP effort config validates sessions and values and notifies slash changes" {+ const Fixture = struct {+ level: []const u8 = "medium",+ narrow: bool = false,+ calls: usize = 0,+ fn config(ctx: *anyopaque, _: Allocator) anyerror!?ConfigOption {+ const self: *@This() = @ptrCast(@alignCast(ctx));+ const broad = &[_]ConfigValue{ .{ .value = "low", .name = "Low" }, .{ .value = "medium", .name = "Medium" }, .{ .value = "high", .name = "High" } };+ const narrow = &[_]ConfigValue{ .{ .value = "low", .name = "Low" }, .{ .value = "medium", .name = "Medium" } };+ return .{ .currentValue = self.level, .options = if (self.narrow) narrow else broad };+ }+ fn set(ctx: *anyopaque, value: []const u8) anyerror!bool {+ const self: *@This() = @ptrCast(@alignCast(ctx));+ for (if (self.narrow) &[_][]const u8{ "low", "medium" } else &[_][]const u8{ "low", "medium", "high" }) |allowed| {+ if (std.mem.eql(u8, value, allowed)) {+ self.level = allowed;+ return true;+ }+ }+ return false;+ }+ fn slash(ctx: *anyopaque, _: Allocator, text: []const u8) anyerror!?[]const u8 {+ const self: *@This() = @ptrCast(@alignCast(ctx));+ if (std.mem.eql(u8, text, "/effort low")) {+ self.level = "low";+ return "effort changed";+ }+ if (std.mem.eql(u8, text, "/model narrow")) {+ self.narrow = true;+ return "model changed";+ }+ return null;+ }+ fn turn(ctx: *anyopaque, _: Allocator, _: []const u8) anyerror![]const u8 {+ const self: *@This() = @ptrCast(@alignCast(ctx));+ self.calls += 1;+ return "done";+ }+ };+ var state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer state.deinit();+ const a = state.allocator();+ var fixture: Fixture = .{};+ var d: Dispatch = .{ .turn = Fixture.turn, .ctx = &fixture, .seed = 1, .config = Fixture.config, .set_config = Fixture.set, .slash = Fixture.slash };+ var buf: [32768]u8 = undefined;+ var w: Io.Writer = .fixed(&buf);+ try handleLine(&d, a, &w, "{\"id\":1,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"acp-1-1\",\"configId\":\"thought_level\",\"value\":\"high\"}}");+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "Unknown session ID") != null);+ w = .fixed(&buf);+ try handleLine(&d, a, &w, "{\"id\":2,\"method\":\"session/new\"}");+ const setup = try std.json.parseFromSliceLeaky(std.json.Value, a, std.mem.sliceTo(w.buffered(), '\n'), .{});+ const option = setup.object.get("result").?.object.get("configOptions").?.array.items[0].object;+ try std.testing.expectEqualStrings("thought_level", option.get("category").?.string);+ try std.testing.expectEqualStrings("medium", option.get("currentValue").?.string);+ try std.testing.expectEqual(@as(usize, 3), option.get("options").?.array.items.len);+ for ([_][]const u8{+ "{\"id\":3,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"wrong\",\"configId\":\"thought_level\",\"value\":\"high\"}}",+ "{\"id\":4,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"acp-1-1\",\"configId\":\"other\",\"value\":\"high\"}}",+ "{\"id\":5,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"acp-1-1\",\"configId\":\"thought_level\",\"value\":\"ultra\"}}",+ "{\"id\":6,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"acp-1-1\",\"configId\":\"thought_level\",\"value\":true}}",+ }) |request| {+ w = .fixed(&buf);+ try handleLine(&d, a, &w, request);+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "\"code\":-32602") != null);+ try std.testing.expectEqualStrings("medium", fixture.level);+ }+ w = .fixed(&buf);+ try handleLine(&d, a, &w, "{\"id\":7,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"acp-1-1\",\"configId\":\"thought_level\",\"value\":\"high\"}}");+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "\"currentValue\":\"high\"") != null);+ try std.testing.expectEqual(@as(usize, 0), fixture.calls);+ w = .fixed(&buf);+ try handleLine(&d, a, &w, "{\"id\":8,\"method\":\"session/prompt\",\"params\":{\"prompt\":[{\"type\":\"text\",\"text\":\"/effort low\"}]}}");+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "config_option_update") != null);+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "\"currentValue\":\"low\"") != null);+ try std.testing.expectEqual(@as(usize, 0), fixture.calls);+ w = .fixed(&buf);+ try handleLine(&d, a, &w, "{\"id\":9,\"method\":\"session/prompt\",\"params\":{\"prompt\":[{\"type\":\"text\",\"text\":\"/model narrow\"}]}}");+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "config_option_update") != null);+ try std.testing.expect(std.mem.indexOf(u8, w.buffered(), "\"value\":\"high\"") == null);+}+test "authenticate names the out-of-band terminal login" {var state = std.heap.ArenaAllocator.init(std.testing.allocator);defer state.deinit();diff --git a/src/acp_inbox.zig b/src/acp_inbox.zigindex c6453230..5937677b 100644--- a/src/acp_inbox.zig+++ b/src/acp_inbox.zig@@ -261,3 +261,23 @@ test "#1007 wait returns a tick when idle" {const ev = (try inbox.wait(arena.allocator())) orelse return error.ExpectedTick;try std.testing.expect(ev == .tick);}++test "session config selection during a turn queues an ordinary request without steering" {+ Agent.esc_cancel.store(false, .release);+ var reader: Io.Reader = .fixed("");+ var inbox: Inbox = .{ .gpa = std.testing.allocator, .io = std.testing.io, .reader = &reader };+ defer inbox.deinit();+ defer Agent.esc_cancel.store(false, .release);+ try inbox.accept("{\"method\":\"session/prompt\",\"params\":{\"sessionId\":\"s\"}}");+ inbox.begin();+ try inbox.accept("{\"id\":2,\"method\":\"session/set_config_option\",\"params\":{\"sessionId\":\"s\",\"configId\":\"thought_level\",\"value\":\"high\"}}");+ try std.testing.expect(!Agent.esc_cancel.load(.acquire));+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena.deinit();+ const first = (try inbox.wait(arena.allocator())) orelse return error.ExpectedLine;+ try std.testing.expect(std.mem.indexOf(u8, first.line, "session/prompt") != null);+ inbox.end();+ const second = (try inbox.wait(arena.allocator())) orelse return error.ExpectedLine;+ try std.testing.expect(std.mem.indexOf(u8, second.line, "session/set_config_option") != null);+ try std.testing.expect(std.mem.indexOf(u8, second.line, "session/prompt") == null);+}diff --git a/src/acp_session_load.zig b/src/acp_session_load.zigindex 91211472..5624a40f 100644--- a/src/acp_session_load.zig+++ b/src/acp_session_load.zig@@ -16,6 +16,8 @@ const invalid_params: i32 = -32602;pub fn configure(d: *engine.Dispatch, live: *LiveTurn) void {d.load_session = load;+ d.config = @import("acp_config.zig").option;+ d.set_config = @import("acp_config.zig").set;d.durable_session_id = if (session.validSessionName(live.root.session_name)) live.root.session_name else null;live.dispatch = d;}@@ -90,6 +92,7 @@ pub fn load(ctx: *anyopaque, arena: Allocator, w: *Io.Writer, req: proto.Requestd.session_id = live.session_id;d.durable_session_id = live.session_id;try replayHistory(arena, live.root, w, live.session_id);- try proto.writeResult(w, req.id, struct {}{});+ const options = engine.configOptions(d, arena) catch |err| return proto.writeError(w, req.id, engine.err_internal, @errorName(err));+ try proto.writeResult(w, req.id, .{ .configOptions = options });try proto.writeAvailableCommands(w, live.session_id, proto.slashCommands());}diff --git a/src/test_hooks.zig b/src/test_hooks.zigindex 5394e5f9..4f5ca292 100644--- a/src/test_hooks.zig+++ b/src/test_hooks.zig@@ -345,6 +345,7 @@ test {_ = @import("experiment_pool.zig");_ = @import("commands_experiment.zig");_ = @import("acp_engine.zig");+ _ = @import("acp_config.zig");_ = @import("libgraff.zig");_ = @import("tui_peer.zig");_ = @import("acp_auth.zig");