mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: make reasoning part text optional in generated types (#23249)
Go serializes ChatMessagePart.Text with omitempty, so empty
reasoning text (from reasoning_start with no delta) is omitted
from JSON. The frontend receives {type: "reasoning"} with text
as undefined, crashing on .trim() calls.
Mark Text as optional in the reasoning variant via the variants
struct tag. This generates ChatReasoningPart with text?: string
and the frontend falls back to "" via nullish coalescing.
Closes #23245
This commit is contained in:
+1
-1
@@ -127,7 +127,7 @@ func AllChatMessagePartTypes() []ChatMessagePartType {
|
||||
// scripts/apitypings/main.go for the codegen that reads these.
|
||||
type ChatMessagePart struct {
|
||||
Type ChatMessagePartType `json:"type"`
|
||||
Text string `json:"text,omitempty" variants:"text,reasoning"`
|
||||
Text string `json:"text,omitempty" variants:"text,reasoning?"`
|
||||
Signature string `json:"signature,omitempty"`
|
||||
ToolCallID string `json:"tool_call_id,omitempty" variants:"tool-call?,tool-result?"`
|
||||
ToolName string `json:"tool_name,omitempty" variants:"tool-call?,tool-result?"`
|
||||
|
||||
Reference in New Issue
Block a user