-
Notifications
You must be signed in to change notification settings - Fork 29
fix(sessions): seed the immediate-retry approval bypass for every approved scope #1800
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
Merged
Aaronontheweb
merged 3 commits into
netclaw-dev:dev
from
Aaronontheweb:fix/shell-approval-redirect-candidate
Aug 7, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
91a4750
fix(sessions): seed the immediate-retry approval bypass for every app…
Aaronontheweb b0ae318
refactor(sessions): extract IsApprovalGrant for the approve-scope pre…
Aaronontheweb 3c7251e
docs: link the approval-bypass fix to netclaw-dev/netclaw#1802
Aaronontheweb 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
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 |
|---|---|---|
|
|
@@ -565,18 +565,21 @@ private async Task<ToolCallResult> ExecuteSingleToolAsync( | |
|
|
||
| sw.Stop(); | ||
|
|
||
| if (decision is ApprovalDecision.ApprovedOnce | ||
| or ApprovalDecision.ApprovedSession | ||
| or ApprovalDecision.ApprovedAlways | ||
| or ApprovalDecision.ApprovedEverywhere) | ||
| if (decision.IsApprovalGrant()) | ||
| { | ||
| // Retry execution now that approval is granted | ||
| // (Approve-once is retried through transient context state; broader scopes | ||
| // are also recorded by the session actor into the shared approval service.) | ||
| if (decision == ApprovalDecision.ApprovedOnce) | ||
|
Collaborator
Author
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. LGTM |
||
| { | ||
| context.Approval.SeedOneTimeApproval(tc.Name, ctx.Patterns); | ||
| } | ||
| // Retry execution now that approval is granted. Seed the one-time | ||
| // bypass for the just-approved call regardless of scope | ||
| // (https://github.com/netclaw-dev/netclaw/issues/1802). Broader | ||
| // scopes (session/always) DO get a durable grant recorded by the | ||
| // session actor, but that grant can legitimately not cover every | ||
| // candidate: a piped command's standalone verbs (base64, head) have | ||
| // no path argument and so are never persisted directory-scoped | ||
| // (by design). Without the transient bypass, the immediate retry | ||
| // re-hits the gate and fails a call the user just approved. This | ||
| // matches the sub-agent loop (SubAgentActor), which seeds for every | ||
| // approved scope. The bypass is per-call, pattern-scoped, and | ||
| // cleared after the attempt, so it cannot leak to any other call. | ||
| context.Approval.SeedOneTimeApproval(tc.Name, ctx.Patterns); | ||
|
|
||
| sw = Stopwatch.StartNew(); | ||
| if (meta is { Background: true } | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -39,6 +39,23 @@ public enum ParentApprovalDecision | |
| TimedOut | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Extensions over <see cref="ParentApprovalDecision"/>. | ||
| /// </summary> | ||
| public static class ParentApprovalDecisionExtensions | ||
|
Collaborator
Author
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. LGTM |
||
| { | ||
| /// <summary> | ||
| /// True when the sub-agent's parent decision grants execution (any approve | ||
| /// scope). Mirrors <c>ApprovalDecision.IsApprovalGrant</c> so the sub-agent | ||
| /// loop classifies approve scopes identically to the parent session paths. | ||
| /// </summary> | ||
| public static bool IsApprovalGrant(this ParentApprovalDecision decision) | ||
| => decision is ParentApprovalDecision.ApprovedOnce | ||
| or ParentApprovalDecision.ApprovedSession | ||
| or ParentApprovalDecision.ApprovedAlways | ||
| or ParentApprovalDecision.ApprovedEverywhere; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Thrown when a sub-agent needs parent approval but the parent session cannot | ||
| /// safely emit an approval prompt with complete authority context. | ||
|
|
||
Oops, something went wrong.
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.
LGTM