Skip to content

feat: prompt AI to prefer ReadMediaFile over Python frame extraction for video analysis#816

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/video-prompt-readmediafile-priority
Open

feat: prompt AI to prefer ReadMediaFile over Python frame extraction for video analysis#816
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/video-prompt-readmediafile-priority

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

Problem

When users upload video files for analysis, the AI was writing Python scripts to extract frames instead of using the built-in ReadMediaFile tool. This behavior was reported in feedback Q-0266.

Solution

Add explicit prompt-level guidance in both tool descriptions to steer the model toward using ReadMediaFile directly for video content:

Changes

  1. read-media.md — Added a new tip in the Tips section:

    When analyzing video files, prefer using ReadMediaFile directly rather than writing Python scripts to extract frames. The model can directly view and understand the video content returned by this tool.

  2. read.md — Reinforced the guidance when describing binary file handling:

    Do not use Python scripts to extract frames from video files — use ReadMediaFile instead.

Why this approach

  • Prompt-level intervention is the most surgical fix — it doesn't change tool behavior or APIs, only guides the model's decision-making
  • Dual coverage — both tools now carry the guidance, so the model sees it whether it considers ReadMediaFile or Read for a video file
  • No regression risk — purely additive prompt text, no code changes to tool execution logic
  • All existing tests pass (73/73)

Test Results

  • : 27/27 passed
  • : 5/5 passed
  • : 46/46 passed

Related

…for video analysis

When users upload video files for analysis, the AI was writing Python scripts
to extract frames instead of using the built-in ReadMediaFile tool. This change
adds explicit prompt-level guidance in both tool descriptions:

- read-media.md: new tip reminding the model to prefer ReadMediaFile directly
  for video analysis rather than writing Python scripts to extract frames
- read.md: reinforces the same guidance when refusing binary/video files,
  explicitly telling the model not to use Python scripts for frame extraction

Fixes the feedback from Q-0266: "Kimi CLI 视频分析希望默认调用 ReadMediaFile
而不是写 Python 切帧".
@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 548aa79

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

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

commit: 548aa79

@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: 548aa7985f

ℹ️ 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 the file doesn't exist or path is invalid, an error will be returned.
- The maximum size that can be read is {{ MAX_MEDIA_MEGABYTES }}MB. An error will be returned if the file is larger than this limit.
- The media content will be returned in a form that you can directly view and understand.
- When analyzing video files, prefer using ReadMediaFile directly rather than writing Python scripts to extract frames. The model can directly view and understand the video content returned by this tool.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict video-only guidance to video-capable models

When the current model has image_in but not video_in (a supported configuration in the capability registry and covered by the read-media tests), ReadMediaFile is still exposed for images, but ReadMediaFileTool.execution rejects video files with “current model does not support video input.” This new unconditional guidance tells the model not to extract frames and to use ReadMediaFile instead, so local video-analysis requests on image-only models are steered into a tool call that must fail instead of the existing frame-extraction fallback. Please make this guidance conditional on video_in or mention the fallback when videos are unsupported.

Useful? React with 👍 / 👎.

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