Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion adk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ This directory provides examples for Eino ADK:
- `supervisor`: basic example of supervisor agent.
- `layered-supervisor`: another example of supervisor agent, which set a supervisor agent as sub-agent of another supervisor agent.
- `integration-project-manager`: another example of using supervisor agent.
- `openclaw-like-agent`: an OpenClaw-style local agent CLI example with workspace awareness, session memory, and skill loading.
- `common`: utils.


Additionally, you can enable [coze-loop](https://github.com/coze-dev/coze-loop) trace for examples, see .example.env for keys.
Additionally, you can enable [coze-loop](https://github.com/coze-dev/coze-loop) trace for examples, see .example.env for keys.
145 changes: 145 additions & 0 deletions adk/multiagent/openclaw-like-agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Eino ADK Multiagent Example: OpenClaw-like Agent

## Description
`openclaw-like-agent` is a workspace-aware local agent example built on Eino ADK.

This example is a reproduction of the recent OpenClaw-style local agent experience using Eino ADK. It shows how to build an OpenClaw-inspired agent pattern with Eino primitives, while keeping the project structure consistent with the other examples in this repository.

Compared with the other `adk/multiagent` demos, this example is closer to a practical local assistant:

- It starts from a standard `main.go` entry and can be launched directly with `go run`.
- It keeps multi-turn conversation history by `session`.
- It creates and manages a dedicated `workspace`.
- It supports loading skills from multiple directories.
- It exposes filesystem and shell capabilities through a restricted backend.

The current implementation is organized as a CLI application, with the main logic living under the `myagent` package.

## Env
Before running it, configure the model-related environment variables:

```bash
# Required
export OPENAI_API_KEY=""
export OPENAI_MODEL=""

# Optional
export OPENAI_BASE_URL=""
export OPENAI_BY_AZURE="false"
```

## Quick Start
Start interactive chat mode:

```bash
go run ./adk/multiagent/openclaw-like-agent
```

Run one single-turn query:

```bash
go run ./adk/multiagent/openclaw-like-agent -- run -q "帮我总结当前 workspace 里有哪些文件"
```

Use a fixed workspace and session:

```bash
go run ./adk/multiagent/openclaw-like-agent -- \
--workspace /tmp/myagent-demo \
--session-id demo \
chat
```

Example interactive output with sensitive information masked:

```text
$ go run main.go
MyAgent TUI
workspace: /path/to/eino-examples/adk/multiagent/openclaw-like-agent/myagent_workspace
session: sess_xxxxxxxxxxxxxxxx
commands: /help /session /history /clear /exit

myagent> 你好

[00:15:09] user> 你好
[run.started] session=sess_xxxxxxxxxxxxxxxx workspace=/path/to/eino-examples/adk/multiagent/openclaw-like-agent/myagent_workspace
[assistant] 你好!很高兴见到你。有什么我可以帮你的吗?

[run.completed] session=sess_xxxxxxxxxxxxxxxx saved_messages=2 at=00:15:12

myagent>
```

## CLI Commands
The root command defaults to interactive chat mode, and also provides several subcommands:

- `chat`: interactive chat mode.
- `run [-q query] [query]`: execute one turn only.
- `session list`: list all sessions in the current workspace.
- `session clear --session-id <id>`: clear conversation history and summary for one session.
- `session delete --session-id <id>`: delete the persisted files for one session.
- `skill list`: list all discovered skills.

Common flags:

- `--workspace`, `-w`: workspace directory. Default is `./myagent_workspace`.
- `--session-id`: session id. Auto-generated when omitted.
- `--instruction`: override the default system instruction.
- `--max-iterations`: max loop iterations for the agent.

## Interactive Commands
In `chat` mode, the following slash commands are supported:

- `/help`
- `/skills`
- `/session`
- `/history`
- `/clear`
- `/exit`

## Workspace Layout
When the agent starts for the first time, it will initialize the workspace automatically:

```text
myagent_workspace/
├── IDENTITY.md
├── artifacts/
├── logs/
├── memory/
│ └── MEMORY.md
├── sessions/
└── skills/
```

Key files and directories:

- `IDENTITY.md`: workspace-level identity override.
- `memory/MEMORY.md`: long-term memory.
- `sessions/`: persisted session metadata and message history.
- `skills/`: workspace-local skills.
- `artifacts/`: files generated during execution.
- `.claude/skills/`: optional skill directory under the workspace. It is supported by the loader, but not created automatically.

## Skill Loading Order
The agent currently loads skills in the following priority order:

1. `<workspace>/skills`
2. `<workspace>/.claude/skills`
3. `~/.claude/skills`
4. `$XDG_CONFIG_HOME/myagent/skills` or `~/.config/myagent/skills`
5. builtin skills directory, defaulting to `./skills`

You can inspect discovered skills with:

```bash
go run ./adk/multiagent/openclaw-like-agent -- skill list
```

## Notes
- The backend is workspace-restricted by default and protects key files such as `IDENTITY.md` and `MEMORY.md`.
- Session history is stored as JSONL under `sessions/`.
- This example has already been wired into the repository as a standard sub-application entry and can be built directly with:

```bash
go build ./adk/multiagent/openclaw-like-agent
```
145 changes: 145 additions & 0 deletions adk/multiagent/openclaw-like-agent/README_ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Eino ADK 多智能体示例:OpenClaw-like Agent

## 简介
`openclaw-like-agent` 是一个基于 Eino ADK 构建的、本地运行的 workspace 感知型 Agent 示例。

这个示例可以理解为基于 Eino ADK 对近期很火的 OpenClaw 风格本地 Agent 体验做的一次复刻。它展示了如何用 Eino 提供的 Agent、工具、session 和 workspace 能力,搭建出一个 OpenClaw 风格的本地 Agent 形态,同时保持与本仓库其他示例一致的项目结构。

和其他 `adk/multiagent` 示例相比,这个例子更接近一个可实际使用的本地助手,也更贴近近期 OpenClaw 风格本地 Agent 的使用方式:

- 通过标准 `main.go` 入口启动,可直接使用 `go run` 运行。
- 支持基于 `session` 的多轮对话历史持久化。
- 自动创建并管理独立的 `workspace`。
- 支持从多个目录加载 skills。
- 通过受限 backend 暴露文件系统与 shell 能力。

当前实现是一个 CLI 应用,核心逻辑位于 `myagent` 包中。

## 环境变量
运行前请先配置模型相关环境变量:

```bash
# 必填
export OPENAI_API_KEY=""
export OPENAI_MODEL=""

# 可选
export OPENAI_BASE_URL=""
export OPENAI_BY_AZURE="false"
```

## 快速开始
启动交互式聊天模式:

```bash
go run ./adk/multiagent/openclaw-like-agent
```

执行单轮请求:

```bash
go run ./adk/multiagent/openclaw-like-agent -- run -q "帮我总结当前 workspace 里有哪些文件"
```

指定固定的 workspace 和 session:

```bash
go run ./adk/multiagent/openclaw-like-agent -- \
--workspace /tmp/myagent-demo \
--session-id demo \
chat
```

脱敏后的交互示例:

```text
$ go run main.go
MyAgent TUI
workspace: /path/to/eino-examples/adk/multiagent/openclaw-like-agent/myagent_workspace
session: sess_xxxxxxxxxxxxxxxx
commands: /help /session /history /clear /exit

myagent> 你好

[00:15:09] user> 你好
[run.started] session=sess_xxxxxxxxxxxxxxxx workspace=/path/to/eino-examples/adk/multiagent/openclaw-like-agent/myagent_workspace
[assistant] 你好!很高兴见到你。有什么我可以帮你的吗?

[run.completed] session=sess_xxxxxxxxxxxxxxxx saved_messages=2 at=00:15:12

myagent>
```

## CLI 命令
根命令默认进入交互式聊天模式,同时也提供以下子命令:

- `chat`:进入交互式聊天模式。
- `run [-q query] [query]`:执行单轮请求。
- `session list`:列出当前 workspace 下的全部 session。
- `session clear --session-id <id>`:清空某个 session 的历史和摘要。
- `session delete --session-id <id>`:删除某个 session 的持久化文件。
- `skill list`:列出当前可发现的所有 skills。

常用参数:

- `--workspace`, `-w`:指定 workspace 目录,默认是 `./myagent_workspace`。
- `--session-id`:指定 session id;不传时自动生成。
- `--instruction`:覆盖默认 system instruction。
- `--max-iterations`:Agent loop 的最大迭代次数。

## 交互模式命令
在 `chat` 模式下,支持以下 slash commands:

- `/help`
- `/skills`
- `/session`
- `/history`
- `/clear`
- `/exit`

## Workspace 目录结构
首次启动时,Agent 会自动初始化 workspace:

```text
myagent_workspace/
├── IDENTITY.md
├── artifacts/
├── logs/
├── memory/
│ └── MEMORY.md
├── sessions/
└── skills/
```

主要目录和文件说明:

- `IDENTITY.md`:workspace 级别的 identity 覆盖文件。
- `memory/MEMORY.md`:长期记忆文件。
- `sessions/`:session 元数据与消息历史持久化目录。
- `skills/`:workspace 本地 skills 目录。
- `artifacts/`:执行过程中产生的产物文件目录。
- `.claude/skills/`:workspace 下可选的 skill 目录,loader 支持读取,但不会自动创建。

## Skill 加载顺序
当前 Agent 按如下优先级加载 skills:

1. `<workspace>/skills`
2. `<workspace>/.claude/skills`
3. `~/.claude/skills`
4. `$XDG_CONFIG_HOME/myagent/skills` 或 `~/.config/myagent/skills`
5. 内置 skills 目录,默认是 `./skills`

你可以用下面的命令查看最终发现的 skills:

```bash
go run ./adk/multiagent/openclaw-like-agent -- skill list
```

## 说明
- backend 默认限制在 workspace 范围内运行,并保护 `IDENTITY.md`、`MEMORY.md` 等关键文件。
- session 历史会以 JSONL 形式持久化到 `sessions/` 目录。
- 这个示例已经作为标准子应用接入仓库,可以直接编译:

```bash
go build ./adk/multiagent/openclaw-like-agent
```
35 changes: 35 additions & 0 deletions adk/multiagent/openclaw-like-agent/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2025 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import (
"fmt"
"os"

"github.com/cloudwego/eino-examples/adk/multiagent/openclaw-like-agent/myagent"
)

func main() {
cmd := myagent.RunMyagentCmd()
cmd.SilenceUsage = true
cmd.SilenceErrors = true

if err := cmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
Loading