feat: add configurable system prompt preamble via file override - #62
Open
NOVA-Openclaw wants to merge 1 commit into
Open
feat: add configurable system prompt preamble via file override#62NOVA-Openclaw wants to merge 1 commit into
NOVA-Openclaw wants to merge 1 commit into
Conversation
Adds resolveSystemPromptPreamble() helper that reads a preamble file from the state directory, replacing the hardcoded 'You are a personal assistant running inside OpenClaw.' string. Resolution order: 1. Config agents.defaults.systemPromptPreambleFile for custom filename 2. Default filename: system-prompt-preamble.md 3. Full path: <stateDir>/<filename> 4. File content used if non-empty (trimmed, CRLF normalized) 5. Falls back to hardcoded default if file missing/empty/unreadable Changes: - New: src/agents/system-prompt-preamble.ts (helper + cache) - Modified: src/agents/system-prompt.ts (both promptMode paths) - Modified: src/agents/system-prompt-config.ts (wire config field) - Modified: src/cli/capability-cli.ts (lazy resolution) - Modified: src/config/types.agent-defaults.ts (schema type) - Modified: src/config/zod-schema.agent-defaults.ts (zod schema) - New: src/agents/system-prompt-preamble.test.ts (unit tests) - New: tests/test-cases-system-prompt-preamble.md (29 test cases) Closes #61
NOVA-Openclaw
force-pushed
the
feature/system-prompt-preamble
branch
from
June 7, 2026 10:51
1d64a32 to
610d8cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a file-based override for the system prompt preamble. If
~/.openclaw/system-prompt-preamble.md(or a custom filename via config) exists in the state directory, its contents replace the hardcoded"You are a personal assistant running inside OpenClaw."string.Motivation
The hardcoded preamble contradicts custom agent personas defined in bootstrap context. Every agent operator should be able to define their own identity framing.
Implementation
resolveSystemPromptPreamble()helper insrc/agents/system-prompt-preamble.tsagents.defaults.systemPromptPreambleFilefor custom filenamesystem-prompt-preamble.md<stateDir>/<filename>stablePromptPrefixCachehash for proper cache invalidationChanges
src/agents/system-prompt-preamble.ts— new helper + cache +clearSystemPromptPreambleCache()for testingsrc/agents/system-prompt.ts— bothpromptMode="none"and mainstablePrefixpaths patchedsrc/agents/system-prompt-config.ts— wires config field through to prompt buildersrc/cli/capability-cli.ts— lazy resolution forLOCAL_MODEL_RUN_SYSTEM_PROMPTsrc/config/types.agent-defaults.ts+zod-schema.agent-defaults.ts— schema forsystemPromptPreambleFilesrc/agents/system-prompt-preamble.test.ts— 18 unit tests covering happy path, fallback, edge cases, caching, filename overridetests/test-cases-system-prompt-preamble.md— 29 test case specificationsBackward Compatibility
When no preamble file exists, behavior is identical to current — zero breaking changes.
Upstream PR Candidate
This is a clean, non-breaking enhancement suitable for upstream PR to openclaw/openclaw.
Closes #61
Closes #43