Skip to content

Commit 1eb6315

Browse files
fix(tools): allow remembered low-risk external write retries
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: Cai-Tang-www <106404101+Cai-Tang-www@users.noreply.github.com>
1 parent f8bead5 commit 1eb6315

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

internal/tools/manager.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,15 @@ func (m *DefaultManager) Execute(ctx context.Context, input ToolCallInput) (Tool
338338
result := blockedToolResult(input, decision)
339339
return result, permissionErrorFromDecision(decision)
340340
}
341+
} else {
342+
result := NewErrorResult(input.Name, "workspace sandbox rejected action", sandboxErrorDetails(action, err), actionMetadata(action))
343+
result.ToolCallID = input.ID
344+
return result, err
341345
}
342-
result := NewErrorResult(input.Name, "workspace sandbox rejected action", sandboxErrorDetails(action, err), actionMetadata(action))
343-
result.ToolCallID = input.ID
344-
return result, err
345-
}
346-
m.auditCapabilityDecision(action, string(security.DecisionAllow), "")
347-
348-
if plan != nil {
346+
} else if plan != nil {
349347
input.WorkspacePlan = plan
350348
}
349+
m.auditCapabilityDecision(action, string(security.DecisionAllow), "")
351350

352351
return m.executor.Execute(ctx, input)
353352
}

internal/tools/manager_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,11 @@ func TestDefaultManagerSandboxOutsideWriteSessionMemory(t *testing.T) {
452452
}
453453

454454
_, err = manager.Execute(context.Background(), input)
455-
if err == nil || !strings.Contains(err.Error(), "escapes workspace root") {
456-
t.Fatalf("expected sandbox rejection after remembered allow, got %v", err)
455+
if err != nil {
456+
t.Fatalf("expected remembered allow retry to pass, got %v", err)
457457
}
458-
if writeTool.callCount != 0 {
459-
t.Fatalf("expected write tool not to execute after remembered allow, got %d", writeTool.callCount)
458+
if writeTool.callCount != 1 {
459+
t.Fatalf("expected write tool to execute after remembered allow, got %d", writeTool.callCount)
460460
}
461461
}
462462

0 commit comments

Comments
 (0)