必须通过API注册为tool才能调用本地程序,直接上传无效;需确认Workspace支持本地工具注册,或封装为HTTP服务(如Flask/CSGLite),再在Agent Space中配置URL、Schema等参数完成注册。
☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 多模态理解力帮你轻松跨越从0到1的创作门槛☜☜☜

要在 Agent Space 中让智能体调用你本地写好的 Python 脚本、Shell 命令或数值模拟程序,不能靠上传文件就自动生效——必须通过 API 注册为可识别、可验证、可沙箱执行的 tool,否则模型生成的调用指令会因无匹配工具而静默失败。
确认 Agent Space 是否支持本地工具注册
登录 https://agent.space/ → 进入 Workspace → 点击左侧导航栏「Settings」→ 查看「Tool Management」或「Custom Tools」选项卡。若页面显示「Add Custom Tool」按钮且支持填写 local path 或 executable command 字段,则当前版本已开放本地工具接入能力;若仅提供 URL 类型的 Webhook 工具配置入口,则说明该 Workspace 实例运行在纯云端沙箱环境,不支持直接调用本地文件系统中的程序。
【必须确保 Workspace 运行在私有部署或边缘节点上,否则本地路径永远无法被访问】
将本地脚本封装为 HTTP 可调用服务(推荐)
这是最稳定、权限可控、日志可追溯的方式,适用于任意语言编写的工具。
方法一:用 Flask 快速启动一个本地 HTTP 服务
新建文件 weather_tool.py,内容如下:
```python
from flask import Flask, request, jsonify
import subprocess
app = Flask(__name__)
@app.route("/api/weather", methods=["POST"])
def get_weather():
data = request.get_json()
city = data.get("city", "Beijing")
try:
result = subprocess.run(
["python3", "./local_weather_cli.py", city],
capture_output=True,
text=True,
timeout=10
)
if result.returncode == 0:
return jsonify({"status": "success", "data": result.stdout})
else:
return jsonify({"status": "error", "msg": result.stderr}), 500
except Exception as e:
return jsonify({"status": "error", "msg": str(e)}), 500
if __name__ == "__main__":
app.run(host="127.0.0.1", port=8081, debug=False)
```
运行命令:python3 weather_tool.py,服务即在 http://127.0.0.1:8081/api/weather 就绪。
方法二:使用 CSGLite 内置的 tool server(如已安装)
CSGLite v2.3+ 提供 csgtool serve 命令,可将任意带标准输入输出的可执行文件暴露为 JSON-RPC 接口。例如你的数值模拟程序叫 simulator,位于 /opt/tools/simulator,则执行:csgtool serve --bin /opt/tools/simulator --port 8082 --method run_simulation,接口地址自动变为 http://localhost:8082/,请求体需含 {"input": {...}} 结构。
在 Agent Space 中注册该工具
第一步:进入 Workspace → Settings → Tool Management → 点击「+ Add Tool」
第二步:填写基础信息
• Tool Name:填 get_local_weather(不能含空格和特殊符号)
• Description:填 Get current weather info for a city using local CLI tool
• Type:选择 HTTP Endpoint
第三步:配置请求参数
• URL:填 http://host.docker.internal:8081/api/weather(⚠️注意:Agent Space 容器内访问宿主机 localhost 不生效,必须用 host.docker.internal)
• Method:选 POST
• Request Body Schema:粘贴以下 JSON Schema,确保模型能正确生成结构化参数:
```json
{
"type": "object",
"properties": {
"city": { "type": "string", "description": "城市中文名,如北京、上海" }
},
"required": ["city"]
}
```
第四步:点击「Save & Validate」,系统会向该地址发送一次测试请求。若返回 HTTP 200 + JSON 且含 "status": "success",则注册成功。


















