Ask each last workflow stage to merge as soon as it finishes

This commit is contained in:
Ian Gulliver
2026-10-21 08:46:51 -07:00
parent b34f9c1511
commit 279919c6cd
6 changed files with 20 additions and 27 deletions
+1 -5
View File
@@ -816,11 +816,7 @@ func (s *Store) ReadyPromptDue(ctx context.Context, id string) (bool, error) {
WHERE t.id = ? AND e.task_id = t.id AND e.seq > t.ready_prompt_seq
AND ((e.kind = 'snapshot.created' AND json_extract(e.payload, '$.trigger') NOT IN (?, ?, ?))
OR (e.kind = 'user.message' AND e.actor != ? AND e.actor NOT LIKE '% (lead)' AND json_extract(e.payload, '$.bounce') IS NOT 1))
) OR EXISTS (
SELECT 1 FROM events e, tasks t, tasks r
WHERE t.id = ? AND t.workflow_run != '' AND r.workflow_run = t.workflow_run AND e.task_id = r.id
AND e.kind = 'task.workflow_finished' AND e.seq > t.ready_prompt_seq
)`, id, string(api.SnapshotTriggerAnswer), string(api.SnapshotTriggerFork), string(api.SnapshotTriggerAskHuman), agentActor, id).Scan(&due)
)`, id, string(api.SnapshotTriggerAnswer), string(api.SnapshotTriggerFork), string(api.SnapshotTriggerAskHuman), agentActor).Scan(&due)
return due, err
}
+1 -1
View File
@@ -204,7 +204,7 @@ func (s *Store) RunEvents(ctx context.Context, run string) ([]api.Event, error)
func (s *Store) RecordStage(ctx context.Context, taskID, output, commit string) error {
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
_, err := tx.ExecContext(ctx, `UPDATE tasks SET stage_output = ?, stage_commit = ? WHERE id = ?`, output, commit, taskID)
_, err := tx.ExecContext(ctx, `UPDATE tasks SET stage_output = ?, stage_commit = ?, ready_prompt_seq = 0 WHERE id = ?`, output, commit, taskID)
if err != nil {
return err
}