























@@ -104,6 +104,7 @@ observation-only.
104104- `agent_turn_prepare` - consume queued plugin turn injections and add same-turn context before prompt hooks
105105- `before_prompt_build` - add dynamic context or system-prompt text before the model call
106106- `before_agent_start` - compatibility-only combined phase; prefer the two hooks above
107+- **`before_agent_run`** - inspect the final prompt and session messages before model submission and optionally block the run
107108- **`before_agent_reply`** - short-circuit the model turn with a synthetic reply or silence
108109- **`before_agent_finalize`** - inspect the natural final answer and request one more model pass
109110- `agent_end` - observe final messages, success state, and run duration
@@ -232,6 +233,22 @@ Use the phase-specific hooks for new plugins:
232233`before_agent_start` remains for compatibility. Prefer the explicit hooks above
233234so your plugin does not depend on a legacy combined phase.
234235236+`before_agent_run` runs after prompt construction and before any model input,
237+including prompt-local image loading and `llm_input` observation. It receives
238+the current user input as `prompt`, plus loaded session history in `messages`
239+and the active system prompt. Return `{ outcome: "block", reason, message? }`
240+to stop the run before the model can read the prompt. `reason` is internal;
241+`message` is the user-facing replacement. The only supported outcomes are
242+`pass` and `block`; unsupported decision shapes fail closed.
243+244+When a run is blocked, OpenClaw stores only the replacement text in
245+`message.content` plus non-sensitive block metadata such as the blocking plugin
246+id and timestamp. The original user text is not retained in transcript or future
247+context. Internal block reasons are treated as sensitive and excluded from
248+transcript, history, broadcast, log, and diagnostics payloads. Observability
249+should use sanitized fields such as blocker id, outcome, timestamp, or a safe
250+category.
251+235252`before_agent_start` and `agent_end` include `event.runId` when OpenClaw can
236253identify the active run. The same value is also available on `ctx.runId`.
237254Cron-driven runs also expose `ctx.jobId` (the originating cron job id) so
@@ -280,8 +297,9 @@ type BeforeAgentFinalizeRetry = {
280297equivalent finalize decisions, and `maxAttempts` caps how many extra passes the
281298host will allow before continuing with the natural final answer.
282299283-Non-bundled plugins that need `llm_input`, `llm_output`,
284-`before_agent_finalize`, or `agent_end` must set:
300+Non-bundled plugins that need raw conversation hooks (`before_model_resolve`,
301+`before_agent_reply`, `llm_input`, `llm_output`, `before_agent_finalize`,
302+`agent_end`, or `before_agent_run`) must set:
285303286304```json
287305{
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。