Secure, Fast, and Extensible Sandbox runtime for AI agents.
fix(execd): skip pair-less allocation for sessions without hosted state
高然c775fe59afe7
diff --git a/components/execd/pkg/runtime/isolated_session_ctrl.go b/components/execd/pkg/runtime/isolated_session_ctrl.goindex 7c4912cd2..10bd0b64c 100644--- a/components/execd/pkg/runtime/isolated_session_ctrl.go+++ b/components/execd/pkg/runtime/isolated_session_ctrl.go@@ -492,18 +492,26 @@ func (r *IsolatedRunner) allocateSessionUppers(session *isolatedSession) error {pairs []isolation.UpperDirPairerr error)- if persistCount == 0 {+ switch {+ case persistCount == 0 && !sessionTmpBindHosted(session):+ // No pairs and no hosted /tmp: keep the historical no-allocation+ // path so these sessions stay independent of the upper quota.+ return nil+ case persistCount == 0:upperID, err = r.upperMgr.AllocateSessionDir()- } else {+ if err == nil {+ session.tmpDir = r.upperMgr.TmpDir(upperID)+ }+ default:upperID, pairs, err = r.upperMgr.AllocateN(persistCount)+ if err == nil && sessionTmpBindHosted(session) {+ session.tmpDir = r.upperMgr.TmpDir(upperID)+ }}if err != nil {return fmt.Errorf("allocate upper: %w", err)}session.upperID = upperID- if sessionTmpBindHosted(session) {- session.tmpDir = r.upperMgr.TmpDir(upperID)- }next := 0for i := range session.overlays {ov := &session.overlays[i]diff --git a/components/execd/pkg/runtime/isolated_session_overlays_test.go b/components/execd/pkg/runtime/isolated_session_overlays_test.goindex 06956786e..41310df24 100644--- a/components/execd/pkg/runtime/isolated_session_overlays_test.go+++ b/components/execd/pkg/runtime/isolated_session_overlays_test.go@@ -237,6 +237,15 @@ func TestCreateIsolatedSession_TmpBindHostedShapes(t *testing.T) {if session == nil {t.Fatal("created session was not published")}+ if !tc.wantHosted {+ // Non-hosted sessions keep the historical no-allocation+ // path and stay independent of the upper quota.+ if session.upperID != "" {+ t.Fatalf("non-hosted session allocated upper entry %q", session.upperID)+ }+ } else if session.upperID == "" {+ t.Fatal("hosted session must own its upper-root subtree")+ }if tc.wantHosted && session.tmpDir == "" {t.Fatal("strict session without /tmp overlay must host /tmp")}