Skip to content

feat: auto-remind ReadMediaFile for video tags to avoid python frame extraction#590

Open
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/video-read-media-reminder
Open

feat: auto-remind ReadMediaFile for video tags to avoid python frame extraction#590
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/video-read-media-reminder

Conversation

@bj456736

@bj456736 bj456736 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Problem

When users paste a video file into the CLI, the TUI converts it into a <video path="...">\</video> tag. Previously the model often tried to write Python scripts to extract frames instead of using the built-in ReadMediaFile tool, which already supports video content natively.

Solution

Auto-inject a system reminder when the user message contains a <video> tag:

The user provided a video file. Use the ReadMediaFile tool to read and analyze the video content directly. Do not write Python scripts or other code to extract frames from the video.

Changes

  • packages/agent-core/src/agent/context/index.ts: Added hasVideoTag() helper and video-reminder injection in appendUserMessage()
  • packages/agent-core/test/agent/context.test.ts: Added tests for both video-tag presence and absence

Test

  • All 25 context tests pass ✅
  • All 48 turn tests pass ✅

Reference

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

…extraction

When users paste a video file into the CLI, the TUI converts it into a
<video path="..."></video> tag. Previously the model often tried to write
Python scripts to extract frames instead of using the built-in ReadMediaFile
tool.

Now, when the user message contains a <video> tag, a system reminder is
automatically injected:
"The user provided a video file. Use the ReadMediaFile tool to read and
analyze the video content directly. Do not write Python scripts or other
code to extract frames from the video."

This fixes the P0 issue from the internal task list where video analysis
would default to Python frame extraction instead of the native tool.
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b808331

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 9, 2026

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

commit: b808331

@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: b808331390

ℹ️ 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 (hasVideoTag(content)) {
this.appendSystemReminder(
'The user provided a video file. Use the ReadMediaFile tool to read and analyze the video content directly. Do not write Python scripts or other code to extract frames from the video.',
{ kind: 'injection', variant: 'host' },

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 Remove video reminders when undoing their prompt

When a video prompt is later undone, this prompt-scoped reminder is left behind because undo() skips messages whose origin is kind: 'injection'. In the /undo scenario after a user submits <video ...></video>, the real user prompt is removed but this reminder remains in context, so the next model request can still be told that the user provided a video file and should use ReadMediaFile even though that prompt was undone.

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