summaryrefslogtreecommitdiff
path: root/subagents
diff options
context:
space:
mode:
Diffstat (limited to 'subagents')
-rw-r--r--subagents/workflow.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/subagents/workflow.lua b/subagents/workflow.lua
index 671890e..ff534cb 100644
--- a/subagents/workflow.lua
+++ b/subagents/workflow.lua
@@ -748,6 +748,11 @@ local function make_workflow_record(id)
return record
end
+local function emit(name)
+ local ext = host()
+ if type(ext.emit) == "function" then pcall(ext.emit, name) end
+end
+
local function notify(record)
if record.suppress_notification or record.status == "cancelled" then return end
local primary = host().agent
@@ -755,9 +760,7 @@ local function notify(record)
local submitted = pcall(primary.submit, primary, string.format(
"[subagents] Workflow %s %s. Inspect subagents.workflows[%q] with subagents.lua.",
record.id, record.status, record.id))
- if submitted and type(host().emit) == "function" then
- pcall(host().emit, "agent_submission")
- end
+ if submitted then emit("agent_submission") end
end
local function finish_workflow(record, status, result, err)
@@ -769,6 +772,7 @@ local function finish_workflow(record, status, result, err)
active_workflows[record.id] = nil
progress.workflow_finished(record.tool_call_id)
notify(record)
+ emit("background_work_end")
end
-- Start a model-authored workflow on its own coroutine and return before the
@@ -826,6 +830,7 @@ function M.start(wf, opts)
end
end)
progress.workflow_started(record.tool_call_id)
+ emit("background_work_start")
return id
end