openclaw - 💡(How to fix) Fix Library embedders: expose `agents.defaults.promptMode` (or document `before_prompt_build` for embedders) [1 comments, 1 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#70084Fetched 2026-04-23 07:29:31
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1
RAW_BUFFERClick to expand / collapse

Minimal system prompt for library embedders

openclaw owns a ~1.7k-tok system prompt + tool schemas on every chat.send turn. Embedders wanting trivial chat pay ~15k input tokens to say "Hello".

Probed buildAgentSystemPrompt in dist/system-prompt-mHpoeHEN.js (13 tools):

promptModechars≈ tokens
full69951749
minimal41371034
none5313

Findings:

  • promptMode isn't user config — derived from sessionKey via isSubagentSessionKey (agent-scope-*.js). "none" unreachable from outside.
  • subagent: prefix gives minimal but drops ## Skills (breaks skills.load.extraDirs), so not viable for library embedders that ship skills.
  • Even in minimal, hardcoded ~480 tok remains: ## OpenClaw CLI Quick Reference (tells the agent to run openclaw gateway status — meaningless when embedded), ## Safety, ## Tooling header, ## Workspace Files (injected) header even with zero files, ## Runtime.
  • before_prompt_build plugin hook CAN wholesale-replace systemPrompt (pi-embedded-runner-C72h-nWV.js:6388, fires on main chat.send, not just subagents). Not documented anywhere obvious — docs/concepts/system-prompt.md just says the prompt is "OpenClaw-owned".

Asks

  1. (ideal) Config-level agents.defaults.promptMode with an "embedded" variant that keeps ## Skills but drops operator-facing sections (CLI Quick Reference / Self-Update / Silent Replies / Heartbeats / Workspace-Files header when empty).
  2. (docs-only) Point docs/concepts/system-prompt.md at before_prompt_build as the official embedder escape hatch. One line + a cookbook snippet would fix most of the discoverability.

Happy to PR #2.

extent analysis

TL;DR

Implement a custom before_prompt_build plugin hook to modify the system prompt for library embedders.

Guidance

  • Investigate the before_prompt_build plugin hook in pi-embedded-runner-C72h-nWV.js to understand how to wholesale-replace the system prompt.
  • Consider creating a custom plugin to drop operator-facing sections (CLI Quick Reference, Self-Update, Silent Replies, Heartbeats, Workspace-Files header when empty) while keeping ## Skills.
  • Review the buildAgentSystemPrompt function in dist/system-prompt-mHpoeHEN.js to understand how the system prompt is constructed.
  • Evaluate the feasibility of adding a config-level agents.defaults.promptMode with an "embedded" variant to simplify the process for library embedders.

Example

// Example of a custom before_prompt_build plugin hook
module.exports = {
  before_prompt_build: (systemPrompt) => {
    // Remove unwanted sections from the system prompt
    systemPrompt = systemPrompt.replace(/## OpenClaw CLI Quick Reference.*/s, '');
    systemPrompt = systemPrompt.replace(/## Safety.*/s, '');
    // ...
    return systemPrompt;
  }
}

Notes

The before_prompt_build plugin hook is not well-documented, and its usage may require additional investigation. The proposed solution may not be applicable to all use cases, and further testing is necessary to ensure compatibility.

Recommendation

Apply workaround: Implement a custom before_prompt_build plugin hook to modify the system prompt, as this approach allows for flexibility and customization.

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 Library embedders: expose `agents.defaults.promptMode` (or document `before_prompt_build` for embedders) [1 comments, 1 participants]