Hooks Overview
Understand pipeline, guard, effect, and resolve by runtime meaning rather than surface syntax
Hooks Overview
The best way to understand this group is not by what the code looks like, but by what actually happens at runtime.
Shared pattern
All four share the same high-level pattern:
- the plugin declares a handler
- the host later calls a named point
For example:
const next = await agent.plugins.pipeline("chat.enrich_message", value);
await agent.plugins.guard("review.require_checked", next);
await agent.plugins.effect("audit.observe", next);
const role = await agent.plugins.resolve("auth.resolve_role", {
userId: "owner",
});In this example, the host is what triggers execution, not the plugin by itself.
Biggest difference between them
pipeline
The key idea is: receive one value, then hand back a new value.
guard
The key idea is: allow the flow to continue, or throw and stop it.
effect
The key idea is: keep the main value untouched and only do side effects.
resolve
The key idea is: only one plugin is allowed to be the final authority for the answer.
Think of them as four kinds of questions
pipeline asks
"Should this value be transformed before the next step?"
guard asks
"Is this value allowed to continue?"
effect asks
"Now that this happened, should we log, sync, or observe something?"
resolve asks
"Who gives the final answer for this point?"
Why resolve is the easiest one to misuse
Many people instinctively write it as if several plugins can each contribute a little.
But resolve is not:
- a collaborative answer-building point
It is:
- a single-authority answer point
That makes it a good fit for things like final role lookup, final provider choice, or final routing decisions, not step-by-step enrichment.