openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

OpenHuman 不执行命令和无反馈的分析

Open stevenyhf opened this issue 6 months ago • 2 comments

核心问题

  1. allowed_commands 极度受限

配置中只允许 12 个命令:
git, npm, cargo, ls, cat, grep, find, echo, pwd, wc, head, tail
大部分常见操作(python, node, mkdir, touch, cp, mv, pip, python3, curl, docker
等)都被安全策略拦截。Agent 尝试执行这些命令时,shell.rs 的 validate_command_execution 会返回类似
"Command not allowed by security policy: " 的错误。

即使 code_executor agent 的 agent.toml 配了 shell 工具,也执行不了大多数命令。

  1. max_actions_per_hour = 20

每小时最多 20 次操作(包括每个工具调用)。用完后所有操作被静默拒绝。对一个正常对话来说太低了。

  1. block_high_risk_commands = true

curl 被归类为 high-risk,被完全阻断。但 http_request 和 web_fetch
工具是单独配置的,如果你用的是这些工具而不是 shell curl,应该没问题。

  1. Medium-risk 命令需要显式审批

require_approval_for_medium_risk = true,而且 auto_approve 列表中只有 file_read, memory_search,
memory_list, get_time, list_dir。mkdir, touch, git push, npm install 等命令都会要求 agent 设置 approved: true,但 agent 不一定会这样做。

反馈问题的相关原因

  1. 后端 API 不可达

日志里反复出现: current user refresh failed: error sending request for url https://api.tinyhumans.ai/auth/me 你配置了代理 http://127.0.0.1:7897,可能代理不通或 backend 不可达。这可能导致 auth token 问题,影响 socket 连接。

  1. Socket.IO 连接状态

前端反馈(tool_call, tool_result, chat_segment 等事件)通过 Socket.IO 传输。如果 socket
连接因认证问题失败,实时反馈就不会到达 UI。前端会一直等待,直到 silence timer(600s)超时才报错。

建议修复方向

快速修复(改配置即可):

1. 扩展允许的命令列表

[autonomy]
allowed_commands = [ "git", "npm", "cargo", "ls", "cat", "grep", "find", "echo", "pwd",
"wc", "head", "tail", "python", "python3", "pip", "node", "mkdir",
"touch", "cp", "mv", "curl", "docker", "make", "cmake", "cd",
"source", "which", "uname", "date", "sort", "uniq", "diff",
"mkdir", "rmdir", "chmod", "tee", "env", "export",
]

2. 提高操作限额

max_actions_per_hour = 200

3. 自动批准常用命令

auto_approve = [
"file_read", "memory_search", "memory_list", "get_time", "list_dir",
"file_write", "shell", "edit", "grep", "glob", "node_exec",
"npm_exec", "web_fetch", "curl",
]

或者临时设成 level = "full" 跳过审批(谨慎)。

网络相关:

检查代理是否正常工作:
curl -x http://127.0.0.1:7897 https://api.tinyhumans.ai/auth/me

要确认当前配置正在生效,编辑 ~/.openhuman/users/6a0921d4095ba1c7a52ef132/config.toml 并重启 core
就行(不需要重新编译)。

stevenyhf avatar May 22 '26 08:05 stevenyhf

max_actions_per_hour = 20, I would like to make this configurable

EvanCarson avatar May 22 '26 15:05 EvanCarson

Update from implementation triage:

  • The max_actions_per_hour configurability requested in https://github.com/tinyhumansai/openhuman/issues/2486#issuecomment-4520060213 has landed on main via #2500 (feat(app): UI control for max_actions_per_hour, merge commit 48548a22). Users can now tune the action budget from Settings -> Advanced, and the config RPC path persists the value.
  • I would keep this issue open for the remaining symptoms in the original report: narrow allowed_commands, approval behavior for medium-risk commands, and the no-feedback path when backend/socket connectivity is unhealthy. Those are separate follow-up fixes from the action-budget knob.

YOMXXX avatar May 23 '26 11:05 YOMXXX