惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
NISL@THU
NISL@THU
S
Securelist
O
OpenAI News
S
Security Affairs
Cyberwarzone
Cyberwarzone
T
Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
C
Cisco Blogs
PCI Perspectives
PCI Perspectives
SecWiki News
SecWiki News
S
Secure Thoughts
GbyAI
GbyAI
I
Intezer
AWS News Blog
AWS News Blog
F
Fortinet All Blogs
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
Google Online Security Blog
Google Online Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
A
About on SuperTechFans
S
Schneier on Security
P
Proofpoint News Feed
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
H
Heimdal Security Blog
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
V
V2EX
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
H
Hacker News: Front Page
Cisco Talos Blog
Cisco Talos Blog
Webroot Blog
Webroot Blog
T
Tenable Blog
MyScale Blog
MyScale Blog
博客园 - 司徒正美
S
SegmentFault 最新的问题
Y
Y Combinator Blog
腾讯CDC
Hacker News: Ask HN
Hacker News: Ask HN
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
面向 AI Agent 的文件系统 - AGFS
微信公众号 · 2026-03-25 · via 陈少文的网站

Please enable Javascript to view the contents

1. AGFS 简介

  • 简介

AGFS 是一个通过 RESTful API 对外提供存储服务的项目。它支持多种存储后端,包括内存、文件、数据库、消息队列等。

由于不需要 POSIX 接口的支持,可以通过远程调用的方式存储数据,这在 AI Agent 中非常有用。

AI Agent 在执行一些工作流时,经常会产生一些中间结果。这些结果需要共享给其他的 Agent 或者用于下一次的 Agent 执行,AGFS 能很好的满足这个需求,特别是在 Sandbox 环境中,AGFS 是一个很合适的选择。

  • 插件化

每个后端服务对应一个插件(MemFS、QueueFS、KVFS、S3FS、SQLFS 等),挂载到统一的目录树中

  • 组件

agfs-server(Go)提供 HTTP API + 插件管理。

agfs-shell(Python)提供交互式 Shell。

agfs-fuse(Go)支持 Linux FUSE 挂载。

agfs-mcp 提供 MCP 协议接入。

  • 与传统方式的映射
传统AGFS
redis.set("key", "value")echo "value" > /kvfs/keys/mykey
sqs.send_message(queue, msg)echo "msg" > /queuefs/q/enqueue
s3.put_object(bucket, key, d)cp file /s3fs/bucket/key
mysql.execute("SELECT ...")echo "SELECT ..." > /sqlfs2/.../query

2. AGFS 部署

  • 准备数据目录
1
2
mkdir -p agfs/data
chmod -R 777 agfs/data
  • 准备配置文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cat > agfs/config.yaml <<'EOF'
server:
  address: ":8080"
  log_level: info

plugins:
  serverinfofs:
    enabled: true
    path: /serverinfo
    config:
      version: "1.0.0"

  memfs:
    enabled: true
    path: /memfs
    config:
      init_dirs:
        - /tmp

  queuefs:
    enabled: true
    path: /queuefs
    config: {}

  kvfs:
    enabled: true
    path: /kvfs
    config:
      initial_data:
        welcome: "Hello from AGFS!"

  heartbeatfs:
    enabled: true
    path: /heartbeatfs

  localfs:
    enabled: true
    path: /local
    config:
      local_dir: /data

  sqlfs:
    - name: local
      enabled: true
      path: /sqlfs
      config:
        backend: sqlite
        db_path: /data/sqlfs.db
        cache_enabled: true
        cache_max_size: 1000
        cache_ttl_seconds: 5

  s3fs:
    - name: s3
      enabled: false
      path: /s3fs
      config:
        region: cn-beijing
        bucket: YOUR_BUCKET
        access_key_id: "YOUR_ACCESS_KEY_ID"
        secret_access_key: "YOUR_SECRET_ACCESS_KEY"
        prefix: agfs/
        endpoint: "YOUR_ENDPOINT"
        disable_ssl: false

  proxyfs:
    - name: remote
      enabled: false
      path: /proxyfs/remote
      config:
        base_url: "http://other-agfs-host:8080/api/v1"
EOF
  • 运行容器
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
nerdctl run -d \
  --name agfs-server \
  --restart always \
  -p 8080:8080 \
  --privileged \
  --device /dev/fuse \
  --cap-add SYS_ADMIN \
  -v $(pwd)/agfs/data:/data \
  -v $(pwd)/agfs/config.yaml:/config.yaml \
  c4pt0r/agfs:latest

也可以使用 SKIP_FUSE_MOUNT=true 环境变量跳过容器内 FUSE 挂载,就不用特权模式、不用挂载 FUSE 设备。

  • 删除容器
1
nerdctl rm -f agfs-server
  • 查看 fuse 挂载点
1
2
3
nerdctl exec -it agfs-server df -h | grep agfs

agfs                      4.0T      2.0T      2.0T  50% /mnt/agfs
  • 查看健康状态
1
curl http://127.0.0.1:8080/api/v1/health
1
{"status":"healthy","version":"1.4.0","gitCommit":"unknown","buildTime":"unknown"}

3. AGFS 功能使用

3.1 Key-Value 存储

通过 KVFS 插件,可以创建和管理键值对。

  • 写入
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/kvfs/keys/hello" \
  -d "world"
1
2
3
4
5
6
7
{"message":"Written 5 bytes"}
``

- 读取

```bash
curl "http://127.0.0.1:8080/api/v1/files?path=/kvfs/keys/hello"
  • 列出所有 Key
1
curl "http://127.0.0.1:8080/api/v1/directories?path=/kvfs/keys/"
1
{"files":[{"name":"hello","size":5,"mode":420,"modTime":"2026-03-25T08:23:51.098035422Z","isDir":false,"meta":{"Name":"kvfs","Type":"file","Content":null}}]}
  • 删除
1
curl -X DELETE "http://127.0.0.1:8080/api/v1/files?path=/kvfs/keys/hello"

3.2 消息队列

通过 QueueFS 插件,可以创建和管理消息队列。

  • 创建队列
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/queuefs/tasks"
  • 入队
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/queuefs/tasks/enqueue" \
  -d "my-message"
1
{"message":"Written 10 bytes"}
  • 查看队列长度
1
curl "http://127.0.0.1:8080/api/v1/files?path=/queuefs/tasks/size"
  • 出队
1
curl "http://127.0.0.1:8080/api/v1/files?path=/queuefs/tasks/dequeue"
1
{"id":"019d2418-6424-7570-873a-311aad406c44","data":"my-message","timestamp":"2026-03-25T08:24:31.52435231Z"}
  • 查看队头

查看不会取出队头消息。

1
curl "http://127.0.0.1:8080/api/v1/files?path=/queuefs/tasks/peek"
1
{"id":"019d2419-7045-7d64-b9e7-8ccb24c9b0cb","data":"my-message","timestamp":"2026-03-25T08:25:40.165873217Z"}

3.3 内存文件系统

通过 MemFS 插件,可以创建和管理内存文件系统。

  • 创建目录
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/memfs/my-memfs"
1
{"message":"directory created"}
  • 写入文件
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/memfs/my-memfs/note.txt" \
  -d "Hello AGFS"
1
{"message":"Written 10 bytes"}
  • 读取文件
1
curl "http://127.0.0.1:8080/api/v1/files?path=/memfs/my-memfs/note.txt"
  • 列出目录
1
curl "http://127.0.0.1:8080/api/v1/directories?path=/memfs/my-memfs"
1
{"files":[{"name":"note.txt","size":10,"mode":420,"modTime":"2026-03-25T08:27:21.323579029Z","isDir":false,"meta":{"Name":"memfs","Type":"file","Content":null}}]}
  • 查看文件元信息
1
curl "http://127.0.0.1:8080/api/v1/stat?path=/memfs/my-memfs/note.txt"
1
{"name":"note.txt","size":10,"mode":420,"modTime":"2026-03-25T08:27:21.323579029Z","isDir":false,"meta":{"Name":"memfs","Type":"file","Content":null}}

3.4 Agent 心跳管理

通过 HeartbeatFS 插件,可以创建和管理 Agent 心跳。

  • 注册 Agent
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/heartbeatfs/agent-1"
1
{"message":"directory created"}
  • 发送心跳
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/heartbeatfs/agent-1/keepalive" \
  -d "ping"
1
{"message":"Written 4 bytes"}
  • 查看状态
1
curl "http://127.0.0.1:8080/api/v1/files?path=/heartbeatfs/agent-1/ctl"
1
2
3
4
last_heartbeat_ts: 2026-03-25T08:32:37Z
expire_ts: 2026-03-25T08:37:37Z
timeout: 300
status: alive

3.5 本地文件系统

通过 localfs 插件,可直接读写容器内映射的本地目录。

  • 上传文件
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/local/kubectl" \
  --data-binary @/usr/bin/kubectl
  • 下载文件
1
2
curl -X GET "http://127.0.0.1:8080/api/v1/files?path=/local/kubectl" \
  -o kubectl-local
  • 写入文件
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/local/test.txt" \
  -d "persistent data"
1
{"message":"Written 15 bytes"}
  • 读取文件
1
curl "http://127.0.0.1:8080/api/v1/files?path=/local/test.txt"

直接 cat $(pwd)/agfs/data/test.txt 也能看到相同内容。

3.6 使用 agfs-shell

  • 进入容器
1
nerdctl exec -it agfs-server /bin/sh

也可以直接执行命令,类似 nerdctl exec -it agfs-server agfs ls /

  • 进入 Shell 交互模式
  • Shell 操作
1
2
3
4
5
6
7
8
9
agfs:/> ls /
dev/
heartbeatfs/
kvfs/
local/
memfs/
queuefs/
serverinfo/
sqlfs/
1
2
3
agfs:/> echo "task-1" > /queuefs/tasks/enqueue
agfs:/> echo "value" > /kvfs/keys/mykey
agfs:/> cat /kvfs/keys/mykey

4. 插件管理

AGFS 支持运行时动态挂载和卸载插件,无需重启服务。

  • 查看已挂载插件
1
curl http://127.0.0.1:8080/api/v1/mounts
1
{"mounts":[{"path":"/dev","pluginName":"devfs"},{"path":"/heartbeatfs","pluginName":"heartbeatfs"},{"path":"/kvfs","pluginName":"kvfs"},{"path":"/local","pluginName":"localfs"},{"path":"/memfs","pluginName":"memfs"},{"path":"/queuefs","pluginName":"queuefs"},{"path":"/serverinfo","pluginName":"serverinfofs"},{"path":"/sqlfs","pluginName":"sqlfs"}]}
  • 动态挂载插件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
curl -X POST http://127.0.0.1:8080/api/v1/mount \
  -H "Content-Type: application/json" \
  -d '{
    "fstype": "s3fs",
    "name": "s3",
    "path": "/s3fs",
    "config": {
      "region": "cn-beijing",
      "bucket": "YOUR_BUCKET",
      "access_key_id": "YOUR_ACCESS_KEY_ID",
      "secret_access_key": "YOUR_SECRET_ACCESS_KEY",
      "prefix": "agfs/",
      "endpoint": "YOUR_ENDPOINT",
      "disable_ssl": false
    }
  }'
1
{"message":"plugin mounted"}
  • 写入文件
1
2
curl -X PUT "http://127.0.0.1:8080/api/v1/files?path=/s3fs/test.txt" \
  -d "Hello AGFS"
1
{"message":"Written 10 bytes"}
  • 卸载插件
1
2
3
curl -X POST http://127.0.0.1:8080/api/v1/unmount \
  -H "Content-Type: application/json" \
  -d '{"path": "/s3fs"}'
1
{"message":"plugin unmounted"}

5. 参考


微信公众号