The open source coding agent.
TypeScript
fix phantom tool call failed messages and empty text parts with some models
Dax Raadf2bdb8159fb6
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.tsindex 5ad6e7da432..799097e85dd 100644--- a/packages/opencode/src/session/index.ts+++ b/packages/opencode/src/session/index.ts@@ -882,7 +882,7 @@ export namespace Session {case "tool-input-start":const part = await updatePart({- id: Identifier.ascending("part"),+ id: toolCalls[value.id]?.id ?? Identifier.ascending("part"),messageID: assistantMsg.id,sessionID: assistantMsg.sessionID,type: "tool",@@ -1029,17 +1029,17 @@ export namespace Session {case "text":if (currentText) {currentText.text += value.text- await updatePart(currentText)+ if (currentText.text) await updatePart(currentText)}breakcase "text-end":- if (currentText && currentText.text) {+ if (currentText) {+ currentText.text = currentText.text.trimEnd()currentText.time = {start: Date.now(),end: Date.now(),}- currentText.text = currentText.text.trimEnd()await updatePart(currentText)}currentText = undefineddiff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.goindex d2da2c60962..a10c13a0f96 100644--- a/packages/tui/internal/components/chat/messages.go+++ b/packages/tui/internal/components/chat/messages.go@@ -281,6 +281,9 @@ func (m *messagesComponent) renderView() tea.Cmd {if part.Synthetic {continue}+ if part.Text == "" {+ continue+ }remainingParts := message.Parts[partIndex+1:]fileParts := make([]opencode.FilePart, 0)for _, part := range remainingParts {@@ -365,6 +368,9 @@ func (m *messagesComponent) renderView() tea.Cmd {if reverted {continue}+ if part.Text == "" {+ continue+ }hasTextPart = truefinished := part.Time.End > 0remainingParts := message.Parts[partIndex+1:]