Enhance message handling in OpenAI adapter to skip non-delta "done" messages

- Added logic to ignore "done" messages that are not delta updates, ensuring that final confirmation messages are not sent to OpenAI clients, which rely on finish_reason instead.
This commit is contained in:
Max 2025-11-17 06:22:18 +08:00
parent b43929210e
commit fa95f32db7

View file

@ -68,6 +68,13 @@ func (a *Adapter) Adapt(msg *message.Message) ([]interface{}, error) {
return []interface{}{}, nil // Return empty array, nothing to send
}
// Skip "done" messages that are not delta updates
// These are final confirmation messages for CUI clients
// OpenAI clients don't need them - they use finish_reason instead
if msg.Done && !msg.Delta {
return []interface{}{}, nil // Return empty array, nothing to send
}
// Get converter for this message type
converter, exists := a.registry.GetConverter(msg.Type)
if !exists {