liveBook · Manning

Agent lifecycle hook

As explained in Vibe Engineering

An agent lifecycle hook is a configured action that runs automatically at a defined point in an AI agent's execution lifecycle.

An agent lifecycle hook runs a configured action at a defined point in an agent’s execution. Unlike a Git hook, which fires on a repository event such as a commit or push, an agent lifecycle hook fires on an event inside the agent’s run, such as session start, session end, a tool call, pre-compact, or stop. section 5.6.5

Hooks provide a way to enforce an action that an instruction alone may not reliably produce. An agent can drift or skip an instruction in AGENTS.md under token pressure. A pre-compact hook addresses a particularly quiet failure: compaction can preserve conclusions while losing the reasoning behind them, leaving the agent confident but missing important context. section 5.6.5

Preserve decisions before compaction

Use a pre-compact hook to enforce a write to a running log of decisions, constraints, and changes in reasoning. Prevent the agent from rereading its own notes in the session that produced them, so it does not compound an earlier mistake. The log remains available to a person, a later session, or another agent picking up the work. section 5.6.5

Hooks can also be packaged in agentic plugins alongside skills, commands, subagent definitions, and MCP configurations. This lets a team distribute a versioned workflow as one unit. Lifecycle event names and coverage vary across agent tools, so check what the chosen tool exposes before relying on a particular hook. section 3.3.6 section 5.6.5

How Vibe Engineering covers it

How deep it goes
Defines lifecycle events and gives a pre-compaction rationale, without providing hook configuration steps.
Examples
Uses a pre-compact hook to enforce a running decision log with a same-session reread restriction.
What you can do after
Evaluate when a lifecycle hook can enforce an action that an agent might otherwise skip.
How it connects
Connects lifecycle hooks to context compaction, Git hooks, agent instructions, and agentic plugins.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.