【Bug已解决】openclaw auto-approve not working / Tool execution still prompts — OpenClaw 自动批准不生效解决方案 【Bug已解决】openclaw: auto-approve not working / Tool execution still prompts — OpenClaw 自动批准不生效解决方案1. 问题描述OpenClaw 使用 --auto-approve 或 --full-auto 时仍弹出审批提示# --auto-approve 不生效 $ openclaw --auto-approve 修改 src/index.js # 仍然弹出审批提示 Approve? (y/n) # 或 --full-auto 不生效 $ openclaw --full-auto 运行 npm install # 仍然要求手动确认 # 或 CI/CD 中卡住 $ openclaw --full-auto --print task 21 # CI/CD 管道卡在审批提示 # 或部分工具不自动批准 $ openclaw --auto-approve task # 文件修改自动批准但命令执行仍提示 Approve command: npm run build? (y/n)这个问题在以下场景中特别常见--auto-approve 配置不正确--full-auto 未启用部分工具需要额外配置CI/CD 环境非交互配置文件覆盖了命令行参数版本不支持2. 原因分析原因分类表原因分类具体表现占比配置覆盖config.json约 30%部分工具限制命令执行约 25%--full-auto 未启用仍提示约 20%CI/CD 非交互卡住约 10%版本不支持旧版约 10%环境变量冲突env约 5%3. 解决方案方案一使用 --full-auto最推荐# 步骤 1使用 --full-auto openclaw --full-auto 修改 src/index.js # 步骤 2CI/CD 中 openclaw --full-auto --print task --max-turns 30 21 # 步骤 3非交互模式 openclaw --full-auto --print --no-stream task 21 # 步骤 4验证 openclaw --full-auto --print hello --max-turns 1方案二检查配置文件# 步骤 1检查配置 cat .openclaw/config.json # 步骤 2如果配置覆盖了 auto-approve python3 -c import json with open(.openclaw/config.json) as f: config json.load(f) config[autoApprove] True config[fullAuto] True with open(.openclaw/config.json, w) as f: json.dump(config, f, indent2) # 步骤 3验证 python3 -m json.tool .openclaw/config.json # 步骤 4测试 openclaw --print task方案三使用环境变量# 步骤 1设置环境变量 export OPENCLAW_AUTO_APPROVEtrue export OPENCLAW_FULL_AUTOtrue # 步骤 2永久设置 echo export OPENCLAW_AUTO_APPROVEtrue ~/.bashrc echo export OPENCLAW_FULL_AUTOtrue ~/.bashrc source ~/.bashrc # 步骤 3CI/CD 中 export OPENCLAW_FULL_AUTOtrue openclaw --print task 21 # 步骤 4验证 openclaw --print hello方案四使用 --yes# 步骤 1使用 --yes 自动确认 openclaw --yes task # 步骤 2或使用 echo y echo y | openclaw task # 步骤 3或使用 yes 命令 yes | openclaw task # 步骤 4CI/CD 中 echo y | openclaw --print task 21方案五检查部分工具限制# 步骤 1有些工具需要额外配置 cat .openclaw/config.json EOF { autoApprove: true, fullAuto: true, allowedTools: [file_edit, file_read, command_run] } EOF # 步骤 2或使用 --allow-tool openclaw --full-auto --allow-tool command_run task # 步骤 3验证 python3 -m json.tool .openclaw/config.json # 步骤 4测试 openclaw --full-auto task方案六更新版本# 步骤 1检查版本 openclaw --version # 步骤 2更新 pip install --upgrade openclaw # 步骤 3验证 --full-auto 支持 openclaw --help | grep -i full-auto\|auto-approve # 步骤 4测试 openclaw --full-auto --print hello --max-turns 14. 各方案对比总结方案适用场景推荐指数难度方案一--full-auto通用⭐⭐⭐⭐⭐低方案二检查配置覆盖⭐⭐⭐⭐⭐低方案三环境变量CI/CD⭐⭐⭐⭐⭐低方案四--yes临时⭐⭐⭐⭐低方案五工具限制部分⭐⭐⭐⭐低方案六更新版本⭐⭐⭐低5. 常见问题 FAQ5.1 --auto-approve 和 --full-auto 的区别--auto-approve: 自动批准大部分操作--full-auto: 完全自动包括命令执行5.2 CI/CD 中如何避免提示使用--full-auto --print --no-stream 环境变量。5.3 配置文件覆盖命令行检查.openclaw/config.json中的autoApprove和fullAuto。5.4 部分工具仍提示使用--allow-tool command_run或allowedTools配置。5.5 如何使用环境变量export OPENCLAW_FULL_AUTOtrue5.6 echo y 管道安全吗临时方案可行但推荐使用--full-auto。5.7 配置中如何设置{ autoApprove: true, fullAuto: true, allowedTools: [file_edit, file_read, command_run] }5.8 --yes 参数是什么自动确认所有提示类似于--full-auto。5.9 旧版本不支持 --full-auto使用pip install --upgrade openclaw更新。5.10 排查清单速查表□ 1. --full-auto 完全自动 □ 2. --full-auto --print --no-stream CI/CD □ 3. config.json: autoApprove fullAuto □ 4. OPENCLAW_FULL_AUTOtrue 环境变量 □ 5. --yes 自动确认 □ 6. echo y | openclaw 管道 □ 7. --allow-tool command_run □ 8. allowedTools 配置 □ 9. openclaw --version 检查版本 □ 10. pip install --upgrade 更新6. 总结根本原因auto-approve 不生效最常见原因是配置覆盖30%和部分工具限制25%最佳实践使用openclaw --full-auto task完全自动模式CI/CD使用--full-auto --print --no-stream 环境变量配置文件设置autoApprove: true和fullAuto: true最佳实践建议使用--full-autoallowedTools配置允许所有工具故障排查流程图flowchart TD A[auto-approve 不生效] -- B[使用 --full-auto] B -- C[openclaw --full-auto task] C -- D{仍提示?} D --|否| E[✅ 问题解决] D --|是| F[检查配置文件] F -- G[cat .openclaw/config.json] G -- H{配置覆盖?} H --|是| I[设置 autoApprove: true] H --|否| j[使用环境变量] I -- K[fullAuto: true] K -- C j -- L[OPENCLAW_FULL_AUTOtrue] L -- C C -- M{仍提示?} M --|否| E M --|是| N[使用 --yes] N -- O[openclaw --yes task] O -- P{仍提示?} P --|否| E P --|是| Q[检查工具限制] Q -- R[--allow-tool command_run] R -- C C -- S{仍提示?} S --|否| E S --|是| T[更新版本] T -- U[pip install --upgrade openclaw] U -- C C -- V{仍提示?} V --|否| E V --|是| W[echo y 管道] W -- X[echo y | openclaw task] X -- E E -- Y[长期: --full-auto config env] Y -- Z[✅ 长期方案]