summaryrefslogtreecommitdiff
path: root/libpanto-lua/src/module.zig
diff options
context:
space:
mode:
Diffstat (limited to 'libpanto-lua/src/module.zig')
-rw-r--r--libpanto-lua/src/module.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/libpanto-lua/src/module.zig b/libpanto-lua/src/module.zig
index 910334f..a707ecd 100644
--- a/libpanto-lua/src/module.zig
+++ b/libpanto-lua/src/module.zig
@@ -488,7 +488,8 @@ fn buildAgent(L: *c.lua_State, box: *AgentBox) ConfigError!void {
) catch return error.AgentInit;
// Pin the store after Agent.init succeeds; the agent/session borrow it.
- c.lua_pushvalue(L, -1);
+ // `luaL_ref` pops the store userdata, leaving the newly created Agent
+ // userdata on top for `agentNew` to return.
box.store_ref = c.luaL_ref(L, LUA_REGISTRYINDEX);
// Ownership of the inner conversation moved into the agent; neuter the