openclaw - 💡(How to fix) Fix [Feature]: Support writable user prompt modification in existing Plugin SDK hooks [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74015Fetched 2026-04-30 06:29:51
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1labeled ×1

The existing llm_input and llm_output plugin hooks are fire-and-forget (return void). This proposal requests making them mutable — allowing hook handlers to return modified prompt, systemPrompt, historyMessages, and assistantTexts — so plugins can transparently transform content before it reaches the LLM and after it comes back.

The primary use case is local data desensitization/resensitization: routing user input through a local model to strip PII before sending to a remote LLM, then restoring it in the output.

Root Cause

The existing llm_input and llm_output plugin hooks are fire-and-forget (return void). This proposal requests making them mutable — allowing hook handlers to return modified prompt, systemPrompt, historyMessages, and assistantTexts — so plugins can transparently transform content before it reaches the LLM and after it comes back.

The primary use case is local data desensitization/resensitization: routing user input through a local model to strip PII before sending to a remote LLM, then restoring it in the output.

RAW_BUFFERClick to expand / collapse

Summary

The existing llm_input and llm_output plugin hooks are fire-and-forget (return void). This proposal requests making them mutable — allowing hook handlers to return modified prompt, systemPrompt, historyMessages, and assistantTexts — so plugins can transparently transform content before it reaches the LLM and after it comes back.

The primary use case is local data desensitization/resensitization: routing user input through a local model to strip PII before sending to a remote LLM, then restoring it in the output.

Problem to solve

Many enterprise and privacy-conscious users need to sanitize sensitive data (names, phone numbers, addresses, credentials) before it leaves the local environment. Currently:

llm_input hook receives prompt, systemPrompt, historyMessages but returns Promise<void> — read-only, cannot mutate. llm_output hook receives assistantTexts but also returns Promise<void> — read-only. before_prompt_build can only prepend/append to the system prompt (prependContext, appendSystemContext); the user's original prompt text is still passed to the LLM unmodified. before_agent_start has the same limitation — no field to rewrite prompt.

Proposed solution

Extend llm_input and llm_output hook signatures to optionally return a mutation result:

// Current (read-only) llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => Promise<void> | void;

// Proposed (mutable) llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) => Promise<PluginHookLlmInputResult | void> | PluginHookLlmInputResult | void;

type PluginHookLlmInputResult = { prompt?: string; // override user prompt systemPrompt?: string; // override system prompt historyMessages?: unknown[]; // override history (for context-level sanitization) };

Alternatives considered

No response

Impact

Enterprise & regulated-industry users — financial services, healthcare, legal, and government teams where data residency and PII protection are mandatory compliance requirements (GDPR, HIPAA, SOC2, etc.). Self-hosted / hybrid deployments — users running OpenClaw locally but connecting to remote LLM providers (OpenAI, Anthropic, etc.) who need to ensure no sensitive data leaves the local boundary. All messaging channels — the gap affects every inbound channel (Telegram, Feishu, Slack, Matrix, etc.) equally, since sanitization must happen at the LLM transport layer, not the channel layer. Plugin developers — anyone building privacy/compliance plugins is blocked from implementing a clean, composable solution within the existing hook system.

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Modify the llm_input and llm_output plugin hooks to return mutable results, allowing plugins to transform content before it reaches the LLM and after it comes back.

Guidance

  • Update the llm_input hook signature to return a Promise<PluginHookLlmInputResult | void> to enable mutation of the prompt, system prompt, and history messages.
  • Introduce a new type PluginHookLlmInputResult to define the structure of the mutable result, including prompt, systemPrompt, and historyMessages properties.
  • Consider the impact on enterprise and regulated-industry users, self-hosted deployments, and plugin developers when implementing this change.
  • Evaluate the proposed solution's effectiveness in addressing the primary use case of local data desensitization and resensitization.

Example

type PluginHookLlmInputResult = {
  prompt?: string;
  systemPrompt?: string;
  historyMessages?: unknown[];
};

llm_input: (event: PluginHookLlmInputEvent, ctx: PluginHookAgentContext) =>
  Promise<PluginHookLlmInputResult | void> | PluginHookLlmInputResult | void;

Notes

The proposed solution requires careful consideration of the implications on the existing plugin ecosystem and the potential impact on performance and security.

Recommendation

Apply the proposed workaround by modifying the llm_input and llm_output plugin hooks to return mutable results, as this addresses the primary use case and provides a flexible solution for plugin developers.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]: Support writable user prompt modification in existing Plugin SDK hooks [1 comments, 2 participants]