Repository navigation
Conversation
Treat FAILED and missing completion as review failures, and retry invalid task_done states instead of accepting them as success. Keep partial scan output and session history aligned with those states.
|
|
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
|
| case "DONE": | ||
| return tool.Complete() | ||
| case "FAILED": | ||
| return tool.Fail("task_done reported FAILED") |
There was a problem hiding this comment.
The resulting error message will be "task failed: task_done reported FAILED", which is slightly redundant. Consider making the Fail() data more descriptive (e.g., include context about why the task failed) or simplifying the wrapping message here to avoid the repetition.
| if name == "task_done" { | ||
| info.Ok = true | ||
| info.Ok = taskDoneSucceeded(args) | ||
| } |
There was a problem hiding this comment.
Potential bug: When taskDoneSucceeded(args) returns true (state is "DONE" or no state), info.Ok is set to true. Later, when the corresponding tool_call record is processed (line 438-439), the matching condition requires !card.ToolCalls[ti].Ok, which will be false for successful task_done calls. This means the Result and DurationMs from the tool_call response record will never be populated for successful task_done calls.
If this is intentional (since successful task_done doesn't need a result), consider adding a comment explaining why. Otherwise, you may want to adjust the matching logic so that Result/DurationMs are still populated even when Ok is already true — perhaps by separating the "needs result" check from the "is failed" check.
| func taskDoneSucceeded(arguments string) bool { | ||
| var args map[string]any | ||
| if err := json.Unmarshal([]byte(arguments), &args); err != nil { | ||
| return false | ||
| } |
There was a problem hiding this comment.
When arguments is empty or not a valid JSON string (e.g., older session records that didn't serialize arguments), json.Unmarshal will fail and this function returns false, marking the task_done as failed. However, the old behavior was to always set info.Ok = true for task_done. This is a behavioral regression for older sessions.
Consider treating unparseable/empty arguments as success (matching the old default behavior) rather than failure, since older records may legitimately lack arguments.
Suggestion:
| func taskDoneSucceeded(arguments string) bool { | |
| var args map[string]any | |
| if err := json.Unmarshal([]byte(arguments), &args); err != nil { | |
| return false | |
| } | |
| func taskDoneSucceeded(arguments string) bool { | |
| if arguments == "" { | |
| return true | |
| } | |
| var args map[string]any | |
| if err := json.Unmarshal([]byte(arguments), &args); err != nil { | |
| return true // treat unparseable args as success for backward compat | |
| } |
Summary
Testing