#22607: feat(cli): add --omit-system-prompt flag to agent --json
cli
commands
size: S
Cluster:
System Prompt Enhancements
Adds `--omit-system-prompt` flag to `openclaw agent --json` that strips `meta.systemPromptReport` from the JSON output.
When piping agent output to other tools, the system prompt report is often unwanted noise. This flag lets users opt out.
## Changes
- `src/cli/program/register.agent.ts`: Register `--omit-system-prompt` option
- `src/commands/agent-via-gateway.ts`: Add `omitSystemPrompt` to `AgentCliOpts`, filter output when flag is set
- `src/commands/agent-via-gateway.e2e.test.ts`: Two new tests
Closes #21607
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds `--omit-system-prompt` flag to `openclaw agent --json` for filtering out `meta.systemPromptReport` from JSON output. This is useful when piping agent output to other tools where the system prompt report is unwanted noise.
**Key changes:**
- Registers new `--omit-system-prompt` CLI option in `register.agent.ts:44`
- Adds `omitSystemPrompt` field to `AgentCliOpts` type
- Implements filtering via `structuredClone` + `delete` in gateway path (lines 159-163)
- Includes comprehensive test coverage for both enabled and default behavior
**Issue found:**
- The flag only works for gateway mode. When using `--local` mode, the flag is silently ignored because the local agent path doesn't implement the filtering logic.
<h3>Confidence Score: 3/5</h3>
- This PR is safe to merge with one logical inconsistency that should be addressed
- Score reflects clean implementation with good test coverage, but the flag only works in gateway mode and silently fails in local mode. This creates inconsistent behavior that could confuse users. The gateway path implementation is correct and well-tested.
- Pay attention to `src/commands/agent-via-gateway.ts` where the local mode fallback doesn't handle the new flag
<sub>Last reviewed commit: 18419e3</sub>
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21055: security(cli): gate systemPromptReport behind --debug flag
by richvincent · 2026-02-19
80.3%
#17221: fix(agents): prevent agents from using exec for gateway management
by CornBrother0x · 2026-02-15
77.5%
#23736: fix(system-prompt): improve prompt cache locality with unique agent ID
by mrx-arafat · 2026-02-22
75.8%
#13068: docs(system-prompt): warn against using exec for gateway restart
by whyuds · 2026-02-10
74.5%
#23522: feat(cli): add --quiet flag and OPENCLAW_NO_TAGLINE env var (#22635)
by dissaozw · 2026-02-22
73.9%
#7983: feat(security): add secure coding guidelines to system prompt
by TGambit65 · 2026-02-03
72.8%
#7382: fix: remove config.schema from agent gateway tool
by kakuteki · 2026-02-02
72.2%
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
71.8%
#11159: fix(cli): parse --profile flag after subcommand name
by hclsys · 2026-02-07
71.7%
#12384: feat(cli): add --stream-json flag for live NDJSON streaming
by kumarabhirup · 2026-02-09
71.6%