Skip to content

feat(agent-core): guide AI to use ReadMediaFile for video analysis instead of manual frame extraction#2183

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:auto-pr-20260725-1800
Open

feat(agent-core): guide AI to use ReadMediaFile for video analysis instead of manual frame extraction#2183
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:auto-pr-20260725-1800

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

Summary

Adds explicit guidance in both the system prompt and the ReadMediaFile tool description to prefer the ReadMediaFile tool over writing Python/ffmpeg scripts when analyzing video content. This prevents inefficient manual frame extraction and leverages built-in multimodal capabilities.

Changes

  • Modified packages/agent-core/src/profile/default/system.md
    • In the "General Guidelines for Research and Data Processing" section, added explicit instruction: When the user provides a video file for analysis, prefer using the ReadMediaFile tool to read it directly rather than writing Python scripts or ffmpeg commands to extract frames manually.
  • Modified packages/agent-core/src/tools/builtin/file/read-media.md
    • Added a tip reinforcing that ReadMediaFile is the preferred way to analyze video content, and the model should not write Python/ffmpeg scripts to extract frames manually.

Motivation

Currently, when users upload video files, the AI often defaults to writing Python scripts with OpenCV or ffmpeg commands to extract frames manually. This approach is:

  • Inefficient — requires installing dependencies, writing boilerplate code, and managing temporary files
  • Error-prone — frame extraction logic can fail on various video formats
  • Redundant — the ReadMediaFile tool already provides native multimodal video reading capabilities

By explicitly guiding the AI to prefer ReadMediaFile for video files at both the system prompt level and the tool description level, we improve user experience and reduce unnecessary code generation.

Testing

  • All agent-core tests pass (223 test files, 4000 tests)

Related

  • Task: Kimi CLI 视频分析希望默认调用 ReadMediaFile 而不是写 Python 切帧 (P0)

…stead of manual frame extraction

- Update system.md to explicitly prefer ReadMediaFile over Python/ffmpeg for video analysis
- Update read-media.md tool description to reinforce video analysis guidance

Fixes P0 task: Kimi CLI 视频分析希望默认调用 ReadMediaFile 而不是写 Python 切帧
@changeset-bot

changeset-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: aa2d189

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/agent-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa2d189e50

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

- If automatic compression cannot safely produce an image within model limits, the tool returns an error and does not send the original image. Follow the error: use Bash or an available image-processing tool to create a smaller copy, then read that copy. Do not retry the unchanged file.
- The system will notify you when there is anything wrong when reading the file.
- This tool is a tool that you typically want to use in parallel. Always read multiple files in one response when possible.
- For video files, this is the preferred way to analyze video content. Do not write Python scripts or ffmpeg commands to extract frames manually — use this tool to read the video directly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Gate the video directive on video input support

For image-only models such as the catalogued OpenAI and Anthropic models, this unconditional directive is included in the tool description because ReadMediaFileTool is registered when either image_in or video_in is enabled. The generated description then contradicts itself by appending “Video files are not supported,” and attempting the instructed call returns an error telling the user to switch models. Prohibiting Python/ffmpeg frame extraction therefore removes the viable fallback for video analysis on these models; add this advice only when video_in is true and retain extraction guidance otherwise.

Useful? React with 👍 / 👎.

@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@aa2d189
npx https://pkg.pr.new/@moonshot-ai/kimi-code@aa2d189

commit: aa2d189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant