Skip to content

Lifecycle hooks

A lifecycle hook runs at a point the harness defines. Gabriel playbook packages can declare BeforeTask and AfterTask in the skill folder’s gabriel/hooks.json.

Event Data provided What a failed check holds
BeforeTask Declared input fields Start of playbook work
AfterTask Declared output fields Acceptance of the result and dependent work

Each hook receives a JSON document on standard input with event, playbook, and the applicable input or output object. Use node with a bundled script and include the script at the matching relative path.

{
"hooks": {
"BeforeTask": [
{ "hooks": [{ "type": "command", "command": "node", "args": ["scripts/check-input.mjs"] }] }
]
}
}

The install preview lists commands for review. The packaged runtime executes supported commands on isolated compute and supplies the declared data over standard input. The child’s lifecycle uses its own pinned skill folder when called by another playbook. Provider-specific CLI tool hooks use a separate runtime path.

A successful hook for the same invocation and payload can be reused when the run resumes. A nonzero exit blocks that invocation. Correct the inputs or skill, review the change, then start a new run. A missing or unverified computer puts the package into setup until the workspace provides supported compute.

When compute cannot confirm the outcome, Gabriel holds the invocation for review. Inspect the existing attempt before starting another. Keep scripts focused on validation so they can be reviewed together with the exact input or output fields they consume.

See code execution, skill folders, and package review, and Standard Agent Specification’s hook lifecycle.