← Back to PRs

#22607: feat(cli): add --omit-system-prompt flag to agent --json

by sleitor open 2026-02-21 11:16 View on GitHub →
cli commands size: S
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