Skip to content

Chat Agent bugfix to treat workspace file references and attachments separately#2717

Draft
GeorgeNgMsft wants to merge 5 commits into
mainfrom
dev/georgeng/fix_chat_file_bug
Draft

Chat Agent bugfix to treat workspace file references and attachments separately#2717
GeorgeNgMsft wants to merge 5 commits into
mainfrom
dev/georgeng/fix_chat_file_bug

Conversation

@GeorgeNgMsft

@GeorgeNgMsft GeorgeNgMsft commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fix chat agent crash on highlighted editor files

Problem

When a user highlights lines in an editor (no upload) and asks a question, the
dispatcher's [Editor context] carries the workspace-relative file path, and the
LLM puts it into chat.generateResponse.relatedFiles. The chat agent assumed
every related file was an uploaded attachment staged under the session's
user_files/, joined the name there, and sessionStorage.read threw ENOENT —
failing the entire response. It also tried to embed every related file as an
image and only handled Windows path separators.

Fix

  • New shared helper rehydrateImageAttachments in typechat-utils (used by
    both chat and dispatcher/search, replacing two near-identical copies). It
    gates on image MIME before any storage read, so a highlighted .yml is
    skipped with zero I/O — no read, no crash. Missing image uploads are caught and
    skipped. Also fixes a latent doubled-image/ data-URL bug and makes the
    user_files lookup portable via path.join (the old \..\user_files\ only
    resolved on Windows).
  • Correct entity typing (relatedFileToEntity): uploaded images →
    ["file","image","data"]; other references → ["file"] (was hardcoded to
    image for everything).
  • Schema nudge: tightened the relatedFiles comment so the model only lists
    uploaded attachment names, not editor/workspace files.
image

@GeorgeNgMsft GeorgeNgMsft reopened this Jul 21, 2026
@GeorgeNgMsft GeorgeNgMsft changed the title Chat Agent bugfix for file path resolution Chat Agent bugfix to treat workspace file references and attachments separately Jul 21, 2026
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