openclaw - 💡(How to fix) Fix Feature Request: Add Custom System Prompt Configuration for Mandatory Rules [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#53727Fetched 2026-04-08 01:24:17
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Root Cause

  1. True "烙印" (branding) - System messages are unignoreable by the model
  2. Cost efficiency - System messages are only sent once per API call, not added to context history
  3. Better caching - Static system prompts can be cached by API providers (like Anthropic's prompt caching)

Code Example

{
  "agent": {
    "systemPrompt": "You must be concise. Never use filler words like 'Great question!' or 'I'd be happy to help!'. Delete unnecessary explanations. Always prefer shorter responses."
  }
}

---

{
  "agent": {
    "systemPromptFile": "system-rules.md"
  }
}
RAW_BUFFERClick to expand / collapse

Feature Request: Add Custom System Prompt Configuration

Problem

Currently, OpenClaw only supports loading files via hooks (like bootstrap-extra-files and before-prompt-build) to inject context into the agent's prompts. However:

  1. Files loaded via hooks are added as user/assistant messages in context, not as system messages
  2. The model can ignore or override rules in these files
  3. There's no way to inject mandatory rules that the model must follow

Use Case

As a user, I want to configure mandatory behavioral rules (like "be concise", "never use markdown unless necessary", "no filler words") that the model cannot ignore.

Proposed Solution

Add a configuration option in openclaw.json to allow users to define a custom system prompt that gets injected as a system message in every API call:

{
  "agent": {
    "systemPrompt": "You must be concise. Never use filler words like 'Great question!' or 'I'd be happy to help!'. Delete unnecessary explanations. Always prefer shorter responses."
  }
}

Or as a file reference:

{
  "agent": {
    "systemPromptFile": "system-rules.md"
  }
}

Why This Matters

  1. True "烙印" (branding) - System messages are unignoreable by the model
  2. Cost efficiency - System messages are only sent once per API call, not added to context history
  3. Better caching - Static system prompts can be cached by API providers (like Anthropic's prompt caching)

Alternatives Considered

  • Hooks system - Only adds content to context, model can ignore
  • Modifying SOUL.md/AGENTS.md - Files are read as context, not enforced as rules
  • Custom hook plugins - Requires developer knowledge, not user-friendly

Environment

  • OpenClaw version: 2026.3.22
  • Model: deepseek/deepseek-chat (via OpenAI-compatible API)

Thank you for considering this feature request!

extent analysis

Fix Plan

To implement the custom system prompt configuration, follow these steps:

  • Update openclaw.json to include the systemPrompt or systemPromptFile option:
{
  "agent": {
    "systemPrompt": "You must be concise. Never use filler words like 'Great question!' or 'I'd be happy to help!'. Delete unnecessary explanations. Always prefer shorter responses."
  }
}

Or

{
  "agent": {
    "systemPromptFile": "system-rules.md"
  }
}
  • Modify the API call to include the custom system prompt as a system message:
import requests

# Load system prompt from openclaw.json
with open('openclaw.json') as f:
    config = json.load(f)
system_prompt = config['agent'].get('systemPrompt')
system_prompt_file = config['agent'].get('systemPromptFile')

if system_prompt_file:
    with open(system_prompt_file, 'r') as f:
        system_prompt = f.read()

# Set up API call with custom system prompt
api_url = 'https://api.example.com/model'
headers = {'Authorization': 'Bearer YOUR_API_KEY'}
data = {
    'prompt': 'Your input prompt',
    'system_message': system_prompt
}

response = requests.post(api_url, headers=headers, json=data)
  • If using a file reference, ensure the file is readable and contains the desired system prompt.

Verification

To verify the fix, check the API response to ensure the custom system prompt is being applied. You can do this by:

  • Checking the response output for the desired behavior (e.g., concise responses without filler words)
  • Using a debugging tool to inspect the API request and response payloads
  • Testing with different input prompts and system prompts to ensure the configuration is working as expected

Extra Tips

  • Ensure the systemPrompt or systemPromptFile option is properly configured in openclaw.json to avoid errors.
  • If using a file reference, make sure the file is in the correct location and is readable by the application.
  • Consider adding error handling and logging to handle cases where the system prompt file is missing or cannot be read.

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 Request: Add Custom System Prompt Configuration for Mandatory Rules [1 participants]