Skip to content

fix(runtime): preserve attachment filenames in model messages - #7979

Open
clean99 wants to merge 1 commit into
CopilotKit:mainfrom
clean99:contrib/preserve-attachment-filenames
Open

clean99 wants to merge 1 commit into
CopilotKit:mainfrom
clean99:contrib/preserve-attachment-filenames

Conversation

@clean99

@clean99 clean99 commented Oct 25, 2026 •

Copy link
Copy Markdown

What does this PR do?

Uploaded attachments carry their filename in metadata.filename, but the runtime drops it when converting audio, video, and document parts to AI SDK file parts. A PDF named invoice.pdf, for example, reaches the model request without its filename even though FilePart supports one.

Copy string filenames for both inline-data and URL sources. Leave missing or non-string filenames absent. The regression tests use createAttachmentContent and cover all three media types with both source types.

Related PRs and Issues

No linked issue. Found while checking attachment conversion.

Checklist

  • I have read the Contribution Guide
  • Documentation reviewed: the existing attachment guide already documents metadata.filename; no public API change.
  • No breaking change.
  • "Allow edits by maintainers" is checked.

Summary by CodeRabbit

  • Bug Fixes
    • Audio, video, and document attachments now preserve filenames from metadata when provided, whether the attachment uses a data or URL source. Missing or invalid filenames remain unset.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8e92e87 and 30fceb7.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ae02a8f and 8e92e87.

Files selected for processing: 2
  • packages/runtime/src/agent/__tests__/multimodal.test.ts
  • packages/runtime/src/agent/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Audio, video, and document attachment conversion now preserves string filenames from metadata for data and URL sources. Tests cover these sources and verify that missing or non-string filenames are omitted.

Changes: Attachment Filename Conversion

Layer / File(s) Summary
Filename propagation and validation
packages/runtime/src/agent/index.ts, packages/runtime/src/agent/__tests__/multimodal.test.ts
Data- and URL-backed audio, video, and document file parts include a filename when metadata.filename is a string. Tests cover these cases and verify that absent or non-string filenames are omitted.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · previous review 8e92e

Filename preservation appears ready to merge after normal checks; no change-specific risk remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(runtime): preserve attachment filenames in model messages" matches the main change. The raw summary shows convertUserMessageContent in packages/runtime/src/agent/index.ts now forwards a…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(runtime): preserve attachment filenames in model messages" matches the main change. The raw summary shows convertUserMessageContent in packages/runtime/src/agent/index.ts now forwards a string metadata.filename as the filename property for audio, video, and document parts with data or URL sources. The multimodal tests add coverage for filename preservation and for absent, null, numeric, or malformed metadata. The PR objectives describe the same intent. The title is specific, concise, and follows the conventional commit style.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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