summaryrefslogtreecommitdiff
path: root/spec/test_luatool.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/test_luatool.lua')
-rw-r--r--spec/test_luatool.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/test_luatool.lua b/spec/test_luatool.lua
index 509b804..e7f2294 100644
--- a/spec/test_luatool.lua
+++ b/spec/test_luatool.lua
@@ -4,6 +4,7 @@
local fake = require("spec.fake_ext")
local jobs = require("subagents.jobs")
local luatool = require("subagents.luatool")
+local progress = require("subagents.progress")
local workflow = require("subagents.workflow")
local uv = require("luv")
@@ -115,6 +116,39 @@ return {
end)
end },
+ { "a background workflow keeps its completed tool entry pinned", function()
+ with_host(function(handle, profiles)
+ progress.reset()
+ progress.begin_live_turn()
+ local pins
+ progress.claim({
+ id = "pinned-workflow-call",
+ tool_name = "subagents.lua",
+ set_component = function()
+ pins = {}
+ return {
+ alive = function() return true end,
+ invalidate = function() end,
+ set_pinned = function(_, value) pins[#pins + 1] = value end,
+ }
+ end,
+ })
+ handle.queue_for("alpha", { output = "finished" })
+ local id = luatool.handle({ source = [[
+ return subagents.workflow(function(ctx)
+ return ctx:agent{name="work", agent="alpha", prompt="go"}:await().output
+ end)
+ ]] }, profiles, { tool_call_id = "pinned-workflow-call" })
+ progress.settle({ id = "pinned-workflow-call" })
+ assert(#pins == 1 and pins[1] == true, "the outer result must not unpin the running workflow")
+
+ local record = pump(id)
+ assert(record.status == "completed", tostring(record.error))
+ assert(#pins == 2 and pins[2] == false, "workflow completion restores transcript order")
+ progress.reset()
+ end)
+ end },
+
{ "a later Lua call inspects workflows and records are read-only", function()
with_host(function(_, profiles)
local id = luatool.handle({ source = [[