From bb85e867bc938138f29fb45230169af1ba60761c Mon Sep 17 00:00:00 2001 From: t Date: Wed, 10 Jun 2026 10:06:07 -0600 Subject: Add addUserText helper; update all call sites Conversation.addUserMessage now takes a []ContentBlock (symmetric with addAssistantMessage). Introduce a thin addUserText wrapper in agent.zig for the plain-text case and update every call site in agent.zig and anthropic_messages_json.zig accordingly. --- src/system_prompt.zig | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/system_prompt.zig') diff --git a/src/system_prompt.zig b/src/system_prompt.zig index 6676442..9dce3e5 100644 --- a/src/system_prompt.zig +++ b/src/system_prompt.zig @@ -330,6 +330,15 @@ fn projectLayerDir(arena: Allocator, io: Io) ![]u8 { const testing = std.testing; +/// Test helper: append a single-text user message (the `addUserMessage` +/// signature now takes a block slice). +fn addUserText(conv: *panto.Conversation, text: []const u8) !void { + const tb = try panto.textualBlockFromSlice(conv.allocator, text); + var block: panto.ContentBlock = .{ .Text = tb }; + errdefer block.deinit(conv.allocator); + try conv.addUserMessage(&.{block}); +} + test "blocksEqual - length and content" { try testing.expect(blocksEqual(&.{ "a", "b" }, &.{ "a", "b" })); try testing.expect(!blocksEqual(&.{ "a", "b" }, &.{ "a", "c" })); @@ -344,7 +353,7 @@ test "effectiveConfigWindow - no replace anchors to leading system blocks" { try conv.addSystemMessage("seed"); try conv.addSystemMessage("append-1"); - try conv.addUserMessage("hi"); + try addUserText(&conv, "hi"); var arena_state = std.heap.ArenaAllocator.init(alloc); defer arena_state.deinit(); @@ -361,10 +370,10 @@ test "effectiveConfigWindow - anchors to last replace block" { defer conv.deinit(); try conv.addSystemMessage("old seed"); - try conv.addUserMessage("hi"); + try addUserText(&conv, "hi"); try conv.replaceSystemMessage("new seed"); try conv.addSystemMessage("new append"); - try conv.addUserMessage("again"); + try addUserText(&conv, "again"); var arena_state = std.heap.ArenaAllocator.init(alloc); defer arena_state.deinit(); -- cgit v1.3