-
Notifications
You must be signed in to change notification settings - Fork 20
OLS-3719, OTA-2090: Check needsRevision() in terminal phases before early return #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jhadvig
wants to merge
4
commits into
openshift:main
Choose a base branch
from
jhadvig:fix-revision-terminal-phases
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−4
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1bee693
OTA-2090: Check needsRevision() in terminal phases before early return
jhadvig 6180ad2
Add test for revision from Completed phase
jhadvig 7f38a67
Address review: narrow revision to Completed phase only
jhadvig d0a2f39
Add Failed phase to revision path
jhadvig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,8 +126,21 @@ func (r *AgenticRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |
| return ctrl.Result{}, nil | ||
| } | ||
|
|
||
| case agenticv1alpha1.AgenticRunPhaseCompleted, | ||
| agenticv1alpha1.AgenticRunPhaseDenied, | ||
| case agenticv1alpha1.AgenticRunPhaseCompleted: | ||
| if !(run.Spec.Execution.IsZero() && needsRevision(&run)) { | ||
| if hasSandboxClaims(&run) { | ||
| if err := r.Agent.ReleaseSandboxes(ctx, &run); err != nil { | ||
| log.Error(err, "sandbox cleanup failed at terminal phase") | ||
| } | ||
| } | ||
| if r.Audit != nil { | ||
| r.Audit.EmitTerminalSpan(ctx, &run, string(phase), terminalReason(&run)) | ||
| r.Audit.Cleanup(&run) | ||
| } | ||
| return ctrl.Result{}, nil | ||
| } | ||
|
|
||
| case agenticv1alpha1.AgenticRunPhaseDenied, | ||
| agenticv1alpha1.AgenticRunPhaseEscalated, | ||
| agenticv1alpha1.AgenticRunPhaseEmergencyStopped: | ||
| if hasSandboxClaims(&run) { | ||
|
|
@@ -142,10 +155,12 @@ func (r *AgenticRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |
| return ctrl.Result{}, nil | ||
|
|
||
| case agenticv1alpha1.AgenticRunPhaseFailed: | ||
| return r.handleFailed(ctx, &run) | ||
| if !(run.Spec.Execution.IsZero() && needsRevision(&run)) { | ||
| return r.handleFailed(ctx, &run) | ||
| } | ||
| } | ||
|
|
||
| // --- Suspension guard (only non-terminal runs reach here) --- | ||
| // --- Suspension guard (non-terminal runs and advisory-only Completed runs needing revision reach here) --- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this comment is stale again now that Failed runs also reach the suspension guard. Suggest "non-terminal runs and advisory-only Completed/Failed runs needing revision reach here". |
||
| suspended, err := isSuspended(ctx, r.Client) | ||
| if err != nil { | ||
| return ctrl.Result{}, err | ||
|
|
@@ -215,6 +230,13 @@ func (r *AgenticRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) | |
| } | ||
| return ctrl.Result{}, nil | ||
|
|
||
| case agenticv1alpha1.AgenticRunPhaseCompleted, | ||
| agenticv1alpha1.AgenticRunPhaseFailed: | ||
| if run.Spec.Execution.IsZero() && needsRevision(&run) { | ||
| return r.handleRevision(ctx, &run, resolved) | ||
| } | ||
| return ctrl.Result{}, nil | ||
|
|
||
| default: | ||
| log.V(1).Info("unhandled phase, no-op", LogKeyPhase, phase) | ||
| return ctrl.Result{}, nil | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observation (not blocking): revision from Failed is really "retry analysis with feedback" (the new test even models an LLM timeout) rather than the documented "feedback requesting changes to the analysis." For advisory only runs the distinction is harmless, and it is arguably a UX win: the Re-analyse button now also recovers from transient analysis failures. Just flagging it so the extension of the
revisionFeedbackcontract is a deliberate choice rather than an accident. If it is intended, a one line addition to the field's doc comment in a follow up would keep the contract honest.