feat(tui): prepend ReadMediaFile hint when video attachments are present#1778
feat(tui): prepend ReadMediaFile hint when video attachments are present#1778bj456736 wants to merge 1 commit into
Conversation
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 切帧'
|
commit: |
There was a problem hiding this comment.
💡 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".
| 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.', |
There was a problem hiding this comment.
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 👍 / 👎.
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:
Test results:
Fixes P0 task: Kimi CLI 视频分析希望默认调用 ReadMediaFile 而不是写 Python 切帧