Skip to content

Commit 628afeb

Browse files
authored
feat(tools): add ReadMediaFile tool for image/video files (#661)
Signed-off-by: Richard Chien <stdrc@outlook.com>
1 parent 69c48a5 commit 628afeb

25 files changed

Lines changed: 640 additions & 251 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Only write entries that are worth mentioning to users.
1111

1212
## Unreleased
1313

14+
- Tool: Add `ReadMediaFile` tool for reading image/video files; `ReadFile` now focuses on text files only
15+
1416
## 0.82 (2026-01-21)
1517

1618
- Tool: Allow `WriteFile` and `StrReplaceFile` tools to edit/write files outside the working directory when using absolute paths

docs/en/customization/agents.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kimi --agent okabe
1414

1515
The default agent, suitable for general use. Enabled tools:
1616

17-
`Task`, `SetTodoList`, `Shell`, `ReadFile`, `Glob`, `Grep`, `WriteFile`, `StrReplaceFile`, `SearchWeb`, `FetchURL`
17+
`Task`, `SetTodoList`, `Shell`, `ReadFile`, `ReadMediaFile`, `Glob`, `Grep`, `WriteFile`, `StrReplaceFile`, `SearchWeb`, `FetchURL`
1818

1919
### `okabe`
2020

@@ -191,13 +191,22 @@ The following are all built-in tools in Kimi CLI.
191191
### `ReadFile`
192192

193193
- **Path**: `kimi_cli.tools.file:ReadFile`
194-
- **Description**: Read file content. Supports text, image, and video files. For text files, max 1000 lines per read, max 2000 characters per line; for image/video files, max 80MB. Files outside working directory require absolute paths.
194+
- **Description**: Read text file content. Max 1000 lines per read, max 2000 characters per line. Files outside working directory require absolute paths.
195+
196+
| Parameter | Type | Description |
197+
|-----------|------|-------------|
198+
| `path` | string | File path |
199+
| `line_offset` | int | Starting line number, default 1 |
200+
| `n_lines` | int | Number of lines to read, default/max 1000 |
201+
202+
### `ReadMediaFile`
203+
204+
- **Path**: `kimi_cli.tools.file:ReadMediaFile`
205+
- **Description**: Read image or video files. Max file size 100MB. Only available when the model supports image/video input. Files outside working directory require absolute paths.
195206

196207
| Parameter | Type | Description |
197208
|-----------|------|-------------|
198209
| `path` | string | File path |
199-
| `line_offset` | int | Starting line number, default 1 (text files only) |
200-
| `n_lines` | int | Number of lines to read, default/max 1000 (text files only) |
201210

202211
### `Glob`
203212

docs/en/release-notes/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This page documents the changes in each Kimi CLI release.
44

55
## Unreleased
66

7+
- Tool: Add `ReadMediaFile` tool for reading image/video files; `ReadFile` now focuses on text files only
8+
79
## 0.82 (2026-01-21)
810

911
- Tool: Allow `WriteFile` and `StrReplaceFile` tools to edit/write files outside the working directory when using absolute paths

docs/zh/customization/agents.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kimi --agent okabe
1414

1515
默认 Agent,适合通常情况使用。启用的工具:
1616

17-
`Task``SetTodoList``Shell``ReadFile``Glob``Grep``WriteFile``StrReplaceFile``SearchWeb``FetchURL`
17+
`Task``SetTodoList``Shell``ReadFile``ReadMediaFile``Glob``Grep``WriteFile``StrReplaceFile``SearchWeb``FetchURL`
1818

1919
### `okabe`
2020

@@ -191,13 +191,22 @@ agent:
191191
### `ReadFile`
192192

193193
- **路径**:`kimi_cli.tools.file:ReadFile`
194-
- **描述**:读取文件内容。支持文本、图片和视频文件。文本文件单次最多读取 1000 行,每行最多 2000 字符;图片/视频文件最大 80MB。工作目录外的文件需使用绝对路径。
194+
- **描述**:读取文本文件内容。单次最多读取 1000 行,每行最多 2000 字符。工作目录外的文件需使用绝对路径。
195+
196+
| 参数 | 类型 | 说明 |
197+
|------|------|------|
198+
| `path` | string | 文件路径 |
199+
| `line_offset` | int | 起始行号,默认 1 |
200+
| `n_lines` | int | 读取行数,默认/最大 1000 |
201+
202+
### `ReadMediaFile`
203+
204+
- **路径**:`kimi_cli.tools.file:ReadMediaFile`
205+
- **描述**:读取图片或视频文件。文件最大 100MB。仅当模型支持图片/视频输入时可用。工作目录外的文件需使用绝对路径。
195206

196207
| 参数 | 类型 | 说明 |
197208
|------|------|------|
198209
| `path` | string | 文件路径 |
199-
| `line_offset` | int | 起始行号,默认 1(仅适用于文本文件) |
200-
| `n_lines` | int | 读取行数,默认/最大 1000(仅适用于文本文件) |
201210

202211
### `Glob`
203212

docs/zh/release-notes/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## 未发布
66

7+
- Tool:添加 `ReadMediaFile` 工具用于读取图片/视频文件;`ReadFile` 现在仅用于读取文本文件
8+
79
## 0.82 (2026-01-21)
810

911
- Tool:`WriteFile``StrReplaceFile` 工具支持使用绝对路径编辑/写入工作目录外的文件

klips/klip-12-wire-initialize-external-tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Author: "@stdrc"
33
Updated: 2026-01-14
4-
Status: Draft
4+
Status: Implemented
55
---
66

77
# KLIP-12: Wire 初始化协商与外部工具调用

src/kimi_cli/acp/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
- When the client advertises `fs.readTextFile` / `fs.writeTextFile`, `ACPKaos` routes
8383
reads and writes through ACP `fs/*` methods.
8484
- `ReadFile` uses `KaosPath.read_lines`, which `ACPKaos` implements via ACP reads.
85+
- `ReadMediaFile` uses `KaosPath.read_bytes` to load image/video payloads through ACP reads.
8586
- `WriteFile` uses `KaosPath.read_text/write_text/append_text` and still generates diffs
8687
and approvals in the tool layer.
8788

src/kimi_cli/agents/default/agent.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ agent:
1212
- "kimi_cli.tools.todo:SetTodoList"
1313
- "kimi_cli.tools.shell:Shell"
1414
- "kimi_cli.tools.file:ReadFile"
15+
- "kimi_cli.tools.file:ReadMediaFile"
1516
- "kimi_cli.tools.file:Glob"
1617
- "kimi_cli.tools.file:Grep"
1718
- "kimi_cli.tools.file:WriteFile"

src/kimi_cli/agents/okabe/agent.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ agent:
99
- "kimi_cli.tools.todo:SetTodoList"
1010
- "kimi_cli.tools.shell:Shell"
1111
- "kimi_cli.tools.file:ReadFile"
12+
- "kimi_cli.tools.file:ReadMediaFile"
1213
- "kimi_cli.tools.file:Glob"
1314
- "kimi_cli.tools.file:Grep"
1415
- "kimi_cli.tools.file:WriteFile"

src/kimi_cli/tools/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def extract_key_argument(json_content: str | streamingjson.Lexer, tool_name: str
5151
if not isinstance(curr_args, dict) or not curr_args.get("path"):
5252
return None
5353
key_argument = _normalize_path(str(curr_args["path"]))
54+
case "ReadMediaFile":
55+
if not isinstance(curr_args, dict) or not curr_args.get("path"):
56+
return None
57+
key_argument = _normalize_path(str(curr_args["path"]))
5458
case "Glob":
5559
if not isinstance(curr_args, dict) or not curr_args.get("pattern"):
5660
return None

0 commit comments

Comments
 (0)