Skip to content

Python: preserve ChatKit input tags in user messages - #8097

Open
vedanth bora (VedanthB) wants to merge 1 commit into
microsoft:mainfrom
VedanthB:fix-chatkit-input-tags
Open

Python: preserve ChatKit input tags in user messages#8097
vedanth bora (VedanthB) wants to merge 1 commit into
microsoft:mainfrom
VedanthB:fix-chatkit-input-tags

Conversation

@VedanthB

Copy link
Copy Markdown

Motivation & Context

ChatKit user messages can contain UserMessageTagContent, but ThreadItemConverter.user_message_to_input only consumed text parts. Mixed-message tags were silently omitted, and a tag-only turn was discarded. This fixes the data loss reported in #8096.

Description & Review Guide

  • Convert input tags through the existing tag_to_message_content extension point.
  • Preserve the original order of text and non-text tag conversions by flushing buffered text around custom content.
  • Keep attachments after the ordered message content, matching the existing behavior.
  • Add regressions for inline text tags, tag-only messages, and custom non-text tag conversion order.

The primary review surface is ThreadItemConverter.user_message_to_input; the remaining changes are focused regression tests.

Related Issue

Fixes #8096

Contribution Checklist

  • The code builds successfully.
  • All new and existing unit tests pass locally.
  • The change follows the repository's contribution and Python coding guidelines.
  • A linked issue documents the bug and no competing issue or pull request was found.
  • The change is backward compatible and preserves existing attachment ordering.

Validation performed:

  • uv run poe check -P chatkit (38 tests, 100% line coverage; formatting, lint, and type checks passed)
  • uv run poe build -P chatkit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug] ChatKit input tags are dropped from user messages

2 participants