Add lifecycle hooks for tasks and the overall workflow graph#116
Draft
Add lifecycle hooks for tasks and the overall workflow graph#116
Conversation
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> Agent-Logs-Url: https://github.com/kitproj/kit/sessions/553f2363-3908-4c91-ba67-90c952a74bf0
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> Agent-Logs-Url: https://github.com/kitproj/kit/sessions/553f2363-3908-4c91-ba67-90c952a74bf0
Copilot
AI
changed the title
[WIP] Discuss potential hooks for project
Add lifecycle hooks for tasks and the overall workflow graph
Mar 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
onSuccessandonFailurelifecycle hooks at two scopes: individual tasks and the overall workflow graph.New types (
internal/types/lifecycle.go)LifecycleHook— specifies a hook command viacommand(array) orsh(inline script), matching the existing task command patternLifecycle— groupsonSuccessandonFailurehooks; nil-safe accessors on bothLifecycleandTaskPer-task hooks (
Task.Lifecycle)Run after a task transitions to
succeededorfailed, before any restart logic:Graph-level hooks (
Spec.Lifecycle)Run when the entire workflow exits.
onSuccessfires only on clean internal completion (not on Ctrl+C);onFailurefires when any task fails without restart. Graph hooks usecontext.Background()since the main context is already cancelled at that point.All hooks are best-effort — failures are logged but do not affect task or graph outcome. JSON schema updated to reflect new types.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.