-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Open
Description
Summary
Currently, copilot.ts detects synthetic user messages (compaction, tool attachments, subtasks) via regex pattern matching on message text. This works but has maintenance coupling.
Current State
synthetic: booleanalready exists onTextPart(message-v2.ts:64)- It's already being set in various places (prompt.ts:1374, etc.)
- BUT
toModelMessage()does not propagate this flag to the finalUIMessage
Proposed Change
-
In
message-v2.tstoModelMessage():- Pass
providerMetadata: { synthetic: true }for user text parts whenpart.synthetic === true - Add same metadata for compaction/subtask generated messages
- Pass
-
In
copilot.ts:- Check
part.providerMetadata?.synthetic === trueinstead of pattern matching - Remove
SYNTHETIC_PATTERNSarray
- Check
Benefits
- Type-safe detection (no string coupling)
- Compile-time enforcement if field is renamed
- Cleaner architecture
- Eliminates theoretical "hackability" of pattern matching
Context
This is a follow-up to #8721 which implements the pattern-matching approach as a minimal fix.
Related issues:
- Copilot auth now sets far too many requests as "user" consuming premium requests rapidly #8030 - Original report of excessive premium request consumption
- GH Copilot | synthetic user messages burn premium requests #8700 - Describes synthetic user messages burning premium requests (same root cause)
- fix: Prevent excessive Copilot premium request consumption #8721 - Pattern-matching fix (immediate solution)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels