summaryrefslogtreecommitdiff
path: root/src/system_prompt.zig
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-06-10 10:06:07 -0600
committert <t@tjp.lol>2026-06-10 12:17:27 -0600
commitbb85e867bc938138f29fb45230169af1ba60761c (patch)
tree5ad1cf50274c61ccfffab7048b4a4e28003d82b5 /src/system_prompt.zig
parentd26890bbc52e9f0050db40f208763a7f2b714ddd (diff)
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.
Diffstat (limited to 'src/system_prompt.zig')
-rw-r--r--src/system_prompt.zig15
1 files changed, 12 insertions, 3 deletions
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();