Let task agents suggest discarding their task, with reasoning

This commit is contained in:
Ian Gulliver
2026-10-19 17:14:13 -07:00
parent 0be09b3279
commit 0dcbfc57f5
7 changed files with 79 additions and 16 deletions
+9 -1
View File
@@ -761,6 +761,14 @@ func (s *Store) SetReadyPromptN(ctx context.Context, id string, snapshotN int) e
}
func (s *Store) MarkReady(ctx context.Context, id, overview, actor string) error {
return s.emitActive(ctx, id, actor, "task.ready", map[string]any{"id": id, "overview": overview})
}
func (s *Store) SuggestDiscard(ctx context.Context, id, reason, actor string) error {
return s.emitActive(ctx, id, actor, "task.discard_suggested", map[string]any{"id": id, "reason": reason})
}
func (s *Store) emitActive(ctx context.Context, id, actor, kind string, payload map[string]any) error {
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
projectID := ""
err := tx.QueryRowContext(ctx, `SELECT project_id FROM tasks WHERE id = ? AND status = ?`, id, string(api.TaskStatusActive)).Scan(&projectID)
@@ -770,7 +778,7 @@ func (s *Store) MarkReady(ctx context.Context, id, overview, actor string) error
if err != nil {
return err
}
return emit(api.Event{Kind: "task.ready", ProjectId: &projectID, TaskId: &id, Actor: actor, Payload: map[string]any{"id": id, "overview": overview}})
return emit(api.Event{Kind: kind, ProjectId: &projectID, TaskId: &id, Actor: actor, Payload: payload})
})
}