graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
note_constraint advertises its byte ceiling (#1764)
Rach Pradhan19c3d120dea0
diff --git a/src/playbook_glue.zig b/src/playbook_glue.zigindex 7859bdbd..4644c900 100644--- a/src/playbook_glue.zig+++ b/src/playbook_glue.zig@@ -113,7 +113,7 @@ pub fn noteConstraint(agent: *Agent, input: std.json.Value) ExecResult {.is_error = true,};if (text.len == 0) return .{ .text = "note_constraint needs non-empty exact text from the current user message", .is_error = true };- if (text.len > playbook.max_text) return .{ .text = "constraint NOT recorded: exact text exceeds the 240-byte project-constraint limit; ask the user for a shorter standing rule", .is_error = true };+ if (text.len > playbook.max_text) return .{ .text = std.fmt.comptimePrint("constraint NOT recorded: exact text exceeds the {d}-byte project-constraint limit; ask the user for a shorter standing rule", .{playbook.max_text}), .is_error = true };const current_user = currentUserText(agent);const answers = @import("ask_user_answers.zig");const from_user = current_user.len > 0 and exactUserSegment(current_user, text);diff --git a/src/schema.zig b/src/schema.zigindex 94d34027..8e598d4d 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -8,6 +8,8 @@ const Allocator = std.mem.Allocator;const mcp = @import("mcp.zig");const pricing = @import("pricing.zig");const learn_store = @import("learn_store.zig");+/// #1764: note_constraint advertises the byte ceiling playbook_glue enforces.+const playbook_max_text = std.fmt.comptimePrint("{d}", .{@import("playbook.zig").max_text});const skill_docs = @import("skill_docs.zig"); // SKILL.md playbooks: the `skill` tool's name/desc/schema live thereconst peer_channel = @import("peer_channel.zig");const workspace_switch = @import("workspace_switch.zig");@@ -124,7 +126,7 @@ const meta_specs = [_]ToolSpec{// by construction — there is no retire/edit/list operation here at all,// so a model that finds a constraint inconvenient has no mechanism to// widen it; only the user can, with /never rm <id-or-text> (#638).- .{ .name = "note_constraint", .desc = "Record an explicit project-wide user rule in this project's playbook (.graff/playbook.jsonl). Do not call for temporary, task/session-limited, or ambiguous steering; follow that locally or ask before persisting. Durable intent must be clear. Pass scope=project and copy text verbatim from the current user message without widening qualifiers. The visible result includes scope, origin, and text plus /never removal guidance. Project records survive compaction and future sessions. Append-only: only the user can retire one with /never rm <id-or-text> (REPL, TUI, or ACP) or an explicit override. Duplicates are harmless.", .schema = "{\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\", \"description\": \"Exact verbatim project-wide constraint from the current user message\"}, \"scope\": {\"type\": \"string\", \"enum\": [\"project\"], \"description\": \"Durable scope; local steering must not be recorded\"}}, \"required\": [\"text\", \"scope\"]}" },+ .{ .name = "note_constraint", .desc = "Record an explicit project-wide user rule in this project's playbook (.graff/playbook.jsonl). Do not call for temporary, task/session-limited, or ambiguous steering; follow that locally or ask before persisting. Durable intent must be clear. Pass scope=project and copy text verbatim from the current user message without widening qualifiers; `text` is at most " ++ playbook_max_text ++ " bytes (UTF-8), so a longer rule cannot be recorded and must not be shortened by dropping qualifiers. The visible result includes scope, origin, and text plus /never removal guidance. Project records survive compaction and future sessions. Append-only: only the user can retire one with /never rm <id-or-text> (REPL, TUI, or ACP) or an explicit override. Duplicates are harmless.", .schema = "{\"type\": \"object\", \"properties\": {\"text\": {\"type\": \"string\", \"description\": \"Exact verbatim project-wide constraint from the current user message, at most " ++ playbook_max_text ++ " bytes\"}, \"scope\": {\"type\": \"string\", \"enum\": [\"project\"], \"description\": \"Durable scope; local steering must not be recorded\"}}, \"required\": [\"text\", \"scope\"]}" },.{.name = "ask_user",.desc = "Ask the human a question and wait for typed text or an option selection. Do not request screenshots or images here unless the active interface explicitly supports attachments in question replies; backend vision support alone is not enough. If that support is absent or unknown and an image is essential, use yield_turn to explain the next-prompt attachment handoff and stop without calling ask_user. Do not ask for permission to pause. Keep the conversation open and do not claim the task is complete. For text questions, put choices in options: the harness renders a numbered picker and blocks for the answer. Ending the turn with a menu written in prose does neither.",diff --git a/src/tool_schema_tests.zig b/src/tool_schema_tests.zigindex 8eb606b2..c827a7b7 100644--- a/src/tool_schema_tests.zig+++ b/src/tool_schema_tests.zig@@ -390,6 +390,12 @@ test "note_constraint (#789): root-only, project-explicit, append-only schema" {try std.testing.expect(std.mem.indexOf(u8, t.desc, "Do not call for temporary") != null);try std.testing.expect(std.mem.indexOf(u8, t.desc, "copy text verbatim") != null);try std.testing.expect(std.mem.indexOf(u8, t.desc, "survive compaction") != null);+ // #1764: the byte ceiling noteConstraint enforces is advertised, from+ // the same constant, so a model never learns it from a rejection.+ const ceiling = std.fmt.comptimePrint("at most {d} bytes", .{@import("playbook.zig").max_text});+ try std.testing.expect(std.mem.indexOf(u8, t.desc, ceiling) != null);+ const text_desc = properties.get("text").?.object.get("description").?.string;+ try std.testing.expect(std.mem.indexOf(u8, text_desc, ceiling) != null);};try std.testing.expect(found);// A subagent must never be handed it: a child never saw the rejection, so