Skip to content

fix: honor per-file review terminal states - #578

Closed
4-1-1 wants to merge 1 commit into
alibaba:mainfrom
4-1-1:codex/fix-review-terminal-state
Closed

4-1-1 wants to merge 1 commit into
alibaba:mainfrom
4-1-1:codex/fix-review-terminal-state

Conversation

@4-1-1

@4-1-1 4-1-1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • honor task_done DONE/FAILED and retry invalid states
  • fail review and scan subtasks that stop without completion
  • align partial scan output and session viewer state

Testing

  • targeted package tests
  • race tests for llmloop, agent, and scan
  • go vet for affected packages

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.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🔍 OpenCodeReview found 3 issue(s) in this PR.

  • ✅ Successfully posted inline: 3 comment(s)

Comment thread internal/llmloop/loop.go
case "DONE":
return tool.Complete()
case "FAILED":
return tool.Fail("task_done reported FAILED")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/viewer/store.go
Comment on lines 388 to 390
if name == "task_done" {
info.Ok = true
info.Ok = taskDoneSucceeded(args)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/viewer/store.go
Comment on lines +502 to +506
func taskDoneSucceeded(arguments string) bool {
var args map[string]any
if err := json.Unmarshal([]byte(arguments), &args); err != nil {
return false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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
}

@4-1-1 4-1-1 closed this Jul 29, 2026
@4-1-1 4-1-1 mentioned this pull request Jul 29, 2026
12 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants