Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
refactor(agent): drop dead Cursor cost fields (CLI reports no cost) (#5852)
Bohan Jiangbce0c0585668
diff --git a/server/pkg/agent/cursor.go b/server/pkg/agent/cursor.goindex 6a4aeceddc..68846607a9 100644--- a/server/pkg/agent/cursor.go+++ b/server/pkg/agent/cursor.go@@ -665,7 +665,15 @@ type cursorStreamEvent struct {// tool_result fieldsOutput string `json:"output,omitempty"`- // result fields+ // result fields.+ //+ // The result event reports token counts only; cursor-agent's stream-json+ // carries no per-turn cost (no `total_cost_usd`, no per-step `cost`). This+ // was verified against the real CLI (2026.07.20, both stream-json and json+ // output) and Cursor's CLI docs. So — unlike Grok, whose turn cost xAI+ // reports authoritatively — Cursor spend is estimated downstream from the+ // static rate table, never carried through here. Add a cost field only+ // when a real payload proves the CLI emits one.ResultText string `json:"result,omitempty"`IsError bool `json:"is_error,omitempty"`InputTokens int64 `json:"inputTokens,omitempty"`@@ -673,7 +681,6 @@ type cursorStreamEvent struct {CacheReadTokens int64 `json:"cacheReadTokens,omitempty"`CacheWriteTokens int64 `json:"cacheWriteTokens,omitempty"`Usage *cursorUsage `json:"usage,omitempty"`- TotalCost float64 `json:"total_cost_usd,omitempty"`// error fieldsErrorMsg string `json:"error,omitempty"`@@ -763,6 +770,9 @@ type cursorTextPart struct {Text string `json:"text"`}+// cursorStepFinishPart carries per-step token counts. cursor-agent does not+// report a per-step cost (see cursorStreamEvent's result-fields note), so only+// tokens are parsed here.type cursorStepFinishPart struct {Tokens struct {Input int `json:"input"`@@ -771,7 +781,6 @@ type cursorStepFinishPart struct {Read int `json:"read"`} `json:"cache"`} `json:"tokens"`- Cost float64 `json:"cost"`}// ── Helpers ──diff --git a/server/pkg/agent/cursor_test.go b/server/pkg/agent/cursor_test.goindex 803a709587..a144948821 100644--- a/server/pkg/agent/cursor_test.go+++ b/server/pkg/agent/cursor_test.go@@ -446,6 +446,8 @@ func TestCursorStepFinishParsing(t *testing.T) {t.Parallel()part := cursorStepFinishPart{}+ // The trailing "cost" key is ignored: cursor-agent does not report per-step+ // cost, and unknown keys must not break token parsing.data := `{"tokens":{"input":500,"output":200,"cache":{"read":100}},"cost":0.01}`if err := json.Unmarshal([]byte(data), &part); err != nil {t.Fatalf("unmarshal: %v", err)