diff options
Diffstat (limited to 'libpanto-lua/src')
| -rw-r--r-- | libpanto-lua/src/module.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libpanto-lua/src/module.zig b/libpanto-lua/src/module.zig index 349a59e..ecf89af 100644 --- a/libpanto-lua/src/module.zig +++ b/libpanto-lua/src/module.zig @@ -602,7 +602,13 @@ fn agentRun(L_opt: ?*c.lua_State) callconv(.c) c_int { var len: usize = 0; const ptr = c.luaL_checklstring(L, 2, &len); - const stream = box.agent.run(.{ .text = ptr[0..len] }) catch + // Open the turn from a single user text block; `run` adopts the block. + const alloc = box.agent.conversation.allocator; + var blocks = [_]panto.ContentBlock{ + .{ .Text = panto.textualBlockFromSlice(alloc, ptr[0..len]) catch + return luaErr(L, "panto: out of memory") }, + }; + const stream = box.agent.run(.{ .blocks = &blocks }) catch return luaErr(L, "panto: failed to start turn"); const ud = c.lua_newuserdatauv(L, @sizeOf(StreamBox), 0) orelse { |
