Skip to content

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

@ElioNeto

Description

@ElioNeto

Original issue tinyhumansai#2486 by @stevenyhf on 2026-05-22T08:49:39Z


核心问题

  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
就行(不需要重新编译)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions