fix(taskrun): serialize RunRecord with snake_case json tags

The task run API was emitting PascalCase fields, so the client never saw status or error_message and treated every disconnect as a network error.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-21 03:05:49 +00:00
co-authored by Cursor
parent f46ab4672e
commit c10206512d
+22 -20
View File
@@ -24,27 +24,29 @@ type CreateRequest struct {
}
// RunRecord 运行实例状态。
// JSON 键与前端约定及 task_runs 列名一致;缺标签时 encoding/json 会输出 PascalCase,
// 前端读 status/error_message 会得到 undefined,断线恢复分支全部失效。
type RunRecord struct {
RunID string
SessionID string
ProjectID int64
UserID int64
ClientTurnID string
IdempotencyKey string // 新 run 稳定键;旧行保持 NULL 不参与唯一索引
TaskKey string
Stage string
WorkflowInstanceID int64
StageInstanceID int64
WorkflowStageKey string
Status string // pending | running | completed | failed | cancelled | pending_author_confirmation | blocked_pending_governance | …
WorkspaceID string
AssistantMsgID int64
WorkerID string
LeaseExpiresAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
ErrorMessage string
Attempt int
RunID string `json:"run_id"`
SessionID string `json:"session_id"`
ProjectID int64 `json:"project_id"`
UserID int64 `json:"user_id"`
ClientTurnID string `json:"client_turn_id"`
IdempotencyKey string `json:"idempotency_key"`
TaskKey string `json:"task_key"`
Stage string `json:"stage"`
WorkflowInstanceID int64 `json:"workflow_instance_id"`
StageInstanceID int64 `json:"stage_instance_id"`
WorkflowStageKey string `json:"workflow_stage_key"`
Status string `json:"status"` // pending | running | completed | failed | cancelled | pending_author_confirmation | blocked_pending_governance | …
WorkspaceID string `json:"workspace_id"`
AssistantMsgID int64 `json:"assistant_message_id"`
WorkerID string `json:"worker_id"`
LeaseExpiresAt *time.Time `json:"lease_expires_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ErrorMessage string `json:"error_message"`
Attempt int `json:"attempt"`
}
// BuildTaskRunIdempotencyKey 新创建用稳定幂等键;空 client_turn 不设键。