Skip to content

Conversation

@stdrc
Copy link
Collaborator

@stdrc stdrc commented Jan 28, 2026

Summary

This PR improves the ReadMediaFile tool by wrapping media content (images/videos) with descriptive XML-like tags for better path traceability.

Changes

  • Wrap media parts with <image path="..."> and <video path="..."> tags instead of using the internal id field
  • Add new utility module kimi_cli/utils/media_tags.py for tag formatting
  • Update related tests and UI components
  • Sync changelog documentation

Before

Media parts used the id field in ImageURLPart/VideoURLPart to store the file path.

After

Media parts are wrapped with descriptive tags:

<image path="/path/to/file.png">
[image data]
</image>

This provides better context about media files in the conversation and improves traceability.


Open with Devin

stdrc added 2 commits January 28, 2026 14:24
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Copilot AI review requested due to automatic review settings January 28, 2026 06:40
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the ReadMediaFile tool to wrap media content (images and videos) with descriptive XML-like tags for better path traceability and context.

Changes:

  • Introduced wrap_media_part utility function that wraps media parts with opening/closing tags containing path attributes
  • Updated ReadMediaFile tool output to return a list of 3 ContentParts (opening tag, media part, closing tag) instead of a single media part
  • Removed usage of the id field in ImageURLPart and VideoURLPart in favor of the wrapping tags approach

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/kimi_cli/utils/media_tags.py New utility module providing wrap_media_part function with HTML-safe attribute formatting
src/kimi_cli/tools/file/read_media.py Updated to wrap image and video parts with descriptive tags containing file paths
src/kimi_cli/ui/shell/prompt.py Updated AttachmentCache.load_content_parts to wrap cached images with tags; removed id parameter from _build_image_part
src/kimi_cli/utils/message.py Simplified string representation by removing id suffix for images and videos
src/kimi_cli/ui/shell/debug.py Removed display of id field for image and video parts in debug output
tests/tools/test_read_media_file.py Updated tests to verify 3-part output structure with opening/closing tags
tests/test_attachment_cache.py Updated tests to verify wrapped content parts from attachment cache
docs/zh/release-notes/changelog.md Added changelog entry; improved consistency by using full-width Chinese colon
docs/en/release-notes/changelog.md Added changelog entry describing the feature
CHANGELOG.md Added changelog entry describing the feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stdrc stdrc merged commit ccba3cc into main Jan 28, 2026
19 checks passed
@stdrc stdrc deleted the rc/better-image-ref branch January 28, 2026 06:45
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.

2 participants