#13068: docs(system-prompt): warn against using exec for gateway restart
agents
stale
Cluster:
System Prompt Enhancements
## Issue Description
Currently, the System Prompt lists `openclaw gateway restart` as a valid command in the "OpenClaw CLI Quick Reference" section without any caveats.
However, using `exec` to run `openclaw gateway restart` performs a hard restart of the service, bypassing the OpenClaw Gateway Tool's state preservation logic (the "Restart Sentinel"). This causes the agent to lose context of the current session and fail to resume the conversation after the restart.
The proper way for an agent to restart the gateway is to use the `gateway` tool (e.g., `gateway(action="restart")`), which writes a sentinel file to disk before restarting, allowing the new process to wake up and reply to the user.
## Proposed Change
Add a warning to the System Prompt in `src/agents/system-prompt.ts` explicitly advising against `exec` usage for restarts when session continuity is desired.
**Before:**
`"- openclaw gateway restart",`
**After:**
`"- openclaw gateway restart (WARNING: does not preserve session context; prefer 'gateway' tool)",`
## Impact
- **Positive**: Reduces the likelihood of agents accidentally "killing themselves" mid-task without a way to report back completion.
- **Negative**: None. The command remains available for emergency use if the agent explicitly decides to use it.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
The PR updates the system prompt’s “OpenClaw CLI Quick Reference” to add an explicit warning that `openclaw gateway restart` does not preserve session context when invoked via `exec`, and to prefer using the `gateway` tool for restarts that need continuity.
Change is localized to `src/agents/system-prompt.ts` and does not affect runtime logic; existing tests that check for the presence of `openclaw gateway restart` still pass because the substring remains present.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Single-string docs-only change in the system prompt; no behavioral code paths altered. Existing prompt tests continue to pass because they match a substring that remains unchanged.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
**Context used:**
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
<!-- /greptile_comment -->
Most Similar PRs
#17221: fix(agents): prevent agents from using exec for gateway management
by CornBrother0x · 2026-02-15
85.3%
#7128: feat: add gateway.restart RPC for graceful in-process restart
by AkashaBot · 2026-02-02
76.6%
#16845: fix(daemon): gateway auto-restart on SIGTERM + agent restart guidel...
by kiminbean · 2026-02-15
76.4%
#9200: Fix: Strip dangerous env vars from baseEnv in host execution
by vishaltandale00 · 2026-02-05
74.9%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
74.8%
#9440: fix(security): warn users when gateway token appears in URLs
by zenchantlive · 2026-02-05
74.6%
#22607: feat(cli): add --omit-system-prompt flag to agent --json
by sleitor · 2026-02-21
74.5%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
74.3%
#7382: fix: remove config.schema from agent gateway tool
by kakuteki · 2026-02-02
74.2%
#14432: System prompt: add guidance for spawning background sub-agents
by vignesh07 · 2026-02-12
74.0%