File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -525,30 +525,25 @@ M.copilot = {
525525 tool_calls = {},
526526 }
527527 elseif output .type == ' response.completed' then
528- -- Completed response
528+ -- Completed response: do NOT resend content here to avoid duplication.
529+ -- Only signal finish and capture usage/reasoning.
529530 local response = output .response
530531 if response then
531- -- Extract content from the output array
532- if response .output and # response .output > 0 then
533- for _ , msg in ipairs (response .output ) do
534- if msg .content and # msg .content > 0 then
535- content = content .. extract_text_from_parts (msg .content )
536- end
537- end
538- end
539-
540- -- Extract reasoning if available
541532 if response .reasoning and response .reasoning .summary then
542533 reasoning = response .reasoning .summary
543534 end
544-
545- -- Extract usage information
546535 if response .usage then
547536 total_tokens = response .usage .total_tokens
548537 end
549-
550538 finish_reason = ' stop'
551539 end
540+ return {
541+ content = ' ' ,
542+ reasoning = reasoning ,
543+ finish_reason = finish_reason ,
544+ total_tokens = total_tokens ,
545+ tool_calls = {},
546+ }
552547 elseif output .type == ' response.content.delta' or output .type == ' response.output_text.delta' then
553548 -- Streaming content delta
554549 if output .delta then
You can’t perform that action at this time.
0 commit comments