Repo Task marked 'completed' when agent exits cleanly without opening a PR#443
Merged
Merged
Conversation
…out PR A Repo Task that completes successfully without opening a PR now transitions to needs_attention instead of completed. This prevents false-positive success badges when the agent exits cleanly but the work never shipped. The fix adds a post-agent check: if the task has a repoUrl, is not a review/planning task, and no PR URL was detected in logs, the system first queries the Git provider API as a fallback. If a PR is found there, the task transitions to pr_opened normally. Otherwise it transitions to needs_attention with a clear message so the user can resume or restart the agent. Also adds a "Completed without PR" label in the UI attention reason formatter, and state machine lifecycle tests for the escalation path. Closes #433 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 tasks
jplorier
pushed a commit
to jplorier/optio
that referenced
this pull request
May 5, 2026
…out PR (jonwiggins#443) A Repo Task that completes successfully without opening a PR now transitions to needs_attention instead of completed. This prevents false-positive success badges when the agent exits cleanly but the work never shipped. The fix adds a post-agent check: if the task has a repoUrl, is not a review/planning task, and no PR URL was detected in logs, the system first queries the Git provider API as a fallback. If a PR is found there, the task transitions to pr_opened normally. Otherwise it transitions to needs_attention with a clear message so the user can resume or restart the agent. Also adds a "Completed without PR" label in the UI attention reason formatter, and state machine lifecycle tests for the escalation path. Closes jonwiggins#433 Co-authored-by: Optio Agent <optio-agent@noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #433
What changed
When a Repo Task's agent exits cleanly but never opens a PR, the task now transitions to
needs_attentioninstead ofcompleted. This prevents false-positive success badges — a Repo Task without a PR means the work didn't ship.Implementation (Option 1 from the issue):
task-worker.ts: After the agent exits successfully, a newshouldEscalateNoPr()check detects when a Repo Task (hasrepoUrl, not a review/planning task) has no detected PR URL. Before escalating, it queries the Git provider API as a fallback — the agent may have pushed a PR that wasn't captured in log output. If a PR is found via API, the task transitions topr_openednormally. Otherwise, it transitions toneeds_attentionwith triggercompleted_without_prand a clear message.task-card.tsx: Added "Completed without PR" to theformatAttentionReason()mapping so the UI shows a human-friendly label in the attention alert.Worktree preserved: The worktree state is set to
preserved(notremoved) so the user can resume from the existing work via the existingneeds_attention → queuedretry flow.What's excluded from escalation:
repoUrl) — they don't produce PRsisReviewTask) — they review existing PRs, not create new onesisPlanningRun) — already handled by existing planning-mode logic!success) — already handled by existing failure logicHow to test
Unit tests:
shouldEscalateNoPr()is a pure exported function with 8 test cases covering all branches (success + no PR → escalate, PR detected → no escalate, review task → no escalate, standalone → no escalate, etc.)State machine tests: New lifecycle tests verify
running → needs_attention → queuedandrunning → needs_attention → cancelledpaths work correctly.Manual E2E: Create a Repo Task with a prompt that makes changes but doesn't open a PR (e.g., "Search the codebase for X and list the files"). After the agent exits, the task should show "Attention" badge with "Completed without PR" instead of "Done".