openclaw - 💡(How to fix) Fix [Bug] Agent automatically executes config commands from example code without user confirmation [1 comments, 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#54416Fetched 2026-04-08 01:27:51
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
commented ×1

Error Message

16:28:59 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.apiKey..."}
16:29:05 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.baseUrl..."}
16:29:11 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.models..."}
16:29:23 - tool call: exec params={"command":"openclaw config set models.providers.deepseek..."}
16:29:32 - tool call: exec params={"command":"openclaw config set agents.defaults.model.primary..."}
16:29:36 - tool call: exec params={"command":"openclaw gateway restart"}

Code Example

16:28:59 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.apiKey..."}
16:29:05 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.baseUrl..."}
16:29:11 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.models..."}
16:29:23 - tool call: exec params={"command":"openclaw config set models.providers.deepseek..."}
16:29:32 - tool call: exec params={"command":"openclaw config set agents.defaults.model.primary..."}
16:29:36 - tool call: exec params={"command":"openclaw gateway restart"}
RAW_BUFFERClick to expand / collapse

Bug Description

When user asks about switching models, the agent automatically executes the example config commands shown in the response, without user confirmation.

Steps to Reproduce

  1. User has sjtu provider configured with minimax-m2.5
  2. User asks: "比如DeepSeek V3.2"
  3. Agent responds with example commands AND automatically executes them:
    • openclaw config set models.providers.deepseek.apiKey "sk-..."
    • openclaw config set models.providers.deepseek.baseUrl "https://api.deepseek.com"
    • openclaw config set agents.defaults.model.primary "deepseek/deepseek-chat"
    • openclaw gateway restart

Expected Behavior

Agent should NOT automatically execute example commands in the response. Example commands are for reference only and should require explicit user execution/approval.

Logs

16:28:59 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.apiKey..."}
16:29:05 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.baseUrl..."}
16:29:11 - tool call: exec params={"command":"openclaw config set models.providers.deepseek.models..."}
16:29:23 - tool call: exec params={"command":"openclaw config set models.providers.deepseek..."}
16:29:32 - tool call: exec params={"command":"openclaw config set agents.defaults.model.primary..."}
16:29:36 - tool call: exec params={"command":"openclaw gateway restart"}

Environment

  • OpenClaw 2026.3.23-2
  • Feishu channel
  • Provider: sjtu (minimax-m2.5)

Severity

High - causes unintended configuration changes without user consent

Suggested Fix

  1. Add confirmation step before executing config-related commands that appear in example code
  2. Or add a system prompt instruction to never auto-execute config commands from example responses
  3. Or clearly mark example commands with a comment like # DO NOT EXECUTE - EXAMPLE ONLY

extent analysis

Fix Plan

To prevent the agent from automatically executing example config commands, we will implement a confirmation step before execution.

Here are the steps:

  • Modify the response generation to include a confirmation prompt for config-related commands.
  • Update the agent's command execution logic to check for user confirmation before executing config commands.

Example Code

# Modified response generation
def generate_response(user_input):
    # ...
    example_commands = [
        "openclaw config set models.providers.deepseek.apiKey \"sk-...\"",
        "openclaw config set models.providers.deepseek.baseUrl \"https://api.deepseek.com\"",
        "openclaw config set agents.defaults.model.primary \"deepseek/deepseek-chat\"",
        "openclaw gateway restart"
    ]
    response = "Example commands:\n" + "\n".join(example_commands)
    response += "\nPlease confirm execution of these commands (yes/no):"
    return response

# Updated command execution logic
def execute_commands(commands):
    for command in commands:
        if command.startswith("openclaw config") or command.startswith("openclaw gateway"):
            user_confirmation = input("Confirm execution of command: " + command + " (yes/no): ")
            if user_confirmation.lower() != "yes":
                print("Command execution cancelled.")
                return
        # Execute the command
        subprocess.run(command, shell=True)

Verification

To verify the fix, test the following scenarios:

  • Ask the agent about switching models and confirm execution of the example commands.
  • Ask the agent about switching models and decline execution of the example commands.
  • Verify that the agent only executes the commands when confirmed by the user.

Extra Tips

  • Consider adding a system prompt instruction to never auto-execute config commands from example responses.
  • Clearly mark example commands with a comment like # DO NOT EXECUTE - EXAMPLE ONLY to avoid confusion.

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