fix: exclude synthetic user messages from chat history processing#312018
Merged
DonJayamanne merged 3 commits intomainfrom Apr 23, 2026
Merged
fix: exclude synthetic user messages from chat history processing#312018DonJayamanne merged 3 commits intomainfrom
DonJayamanne merged 3 commits intomainfrom
Conversation
Co-authored-by: Copilot <copilot@github.com>
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts Copilot CLI chat-history reconstruction to ignore “synthetic” user.message events (e.g. skill invocations) so the VS Code chat UI doesn’t mis-render or attribute turns incorrectly (fixes #310897).
Changes:
- Prevent
sdkRequestIdfrom being overwritten by subsequentuser.messageevents during a single request. - Filter out synthetic
user.messageevents when rebuilding chat turns, including when determining the “last user message”. - Introduce
isSyntheticUserMessage(...)helper for the filtering logic.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts | Keeps the first captured SDK request ID for metadata mapping, avoiding later overwrites. |
| extensions/copilot/src/extension/chatSessions/copilotcli/common/copilotCLITools.ts | Skips synthetic user messages during history building and adds helper used for filtering. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/copilot/src/extension/chatSessions/copilotcli/common/copilotCLITools.ts:1745
isSyntheticUserMessagecurrently returnstruewhenevent.data.sourceis missing or equals'user', which will classify normal user messages (including ones emitted by this extension that don't setsource) as synthetic. This will cause user turns to be skipped inbuildChatHistoryFromEventsand likely break history rendering/tests. Invert the predicate so only explicitly non-user sources (e.g. skill/system) are treated as synthetic, and treat missing/emptysourceas a regular user message.
export function isSyntheticUserMessage(event: Extract<SessionEvent, { type: 'user.message' }>): boolean {
return event.type === 'user.message' && (!event.data.source || (event.data.source ?? '').toLowerCase() === 'user');
}
- Files reviewed: 2/2 changed files
- Comments generated: 1
Contributor
Author
|
@copilot fix the test failures in copilotCLITools.spec.ts, copilotCliSessionService.spec.ts |
Copilot stopped work on behalf of
DonJayamanne due to an error
April 23, 2026 20:05
dmitrivMS
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Co-authored-by: Copilot copilot@github.com
Fixes #310897