Skip to content

feat(tui): prepend ReadMediaFile hint when video attachments are present#1778

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

feat(tui): prepend ReadMediaFile hint when video attachments are present#1778
bj456736 wants to merge 1 commit into
MoonshotAI:mainfrom
bj456736:feat/video-readmediafile-hint

Conversation

@bj456736

Copy link
Copy Markdown
Contributor

When users attach a video to a prompt, the model sometimes tries to write Python or Bash scripts to extract frames instead of using the built-in ReadMediaFile tool.

This change prepends a short prompt hint to the message parts whenever video attachments are detected, explicitly asking the model to use ReadMediaFile for direct video analysis.

Changes:

  • Modified "extractMediaAttachments" in "image-placeholder.ts" to prepend a hint text part when videoAttachmentIds.length > 0
  • Updated unit tests in "image-placeholder.test.ts" to expect the new hint part

Test results:

  • All 19 tests in image-placeholder.test.ts pass

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

When users attach a video to a prompt, the model sometimes tries to
write Python or Bash scripts to extract frames instead of using the
built-in ReadMediaFile tool.

This change prepends a short prompt hint to the message parts whenever
video attachments are detected, explicitly asking the model to use
ReadMediaFile for direct video analysis.

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

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 407edb9

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 Jul 16, 2026

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

commit: 407edb9

@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: 407edb9c52

ℹ️ 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".

Comment on lines +95 to +99
parts.unshift({
type: 'text',
text:
'Use the ReadMediaFile tool to read and analyze the attached video directly. ' +
'Do not write Python scripts or Bash commands to extract frames.',

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 Exclude injected video hints from prompt metadata

When a normal prompt contains a video, this prepends the internal tool hint as the first text part sent to session.prompt. The session metadata builders (promptMetadataTextFromPayload / promptMetadataTextFromContentParts) derive lastPrompt and the initial title from every text part and only strip image-compression captions, so a new session started with summarize [video] will be titled with this ReadMediaFile instruction and expose it in last_prompt instead of the user's prompt. Please route this hint through a hidden/system-reminder path or strip it from metadata/history projection like compression captions.

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