From 811cab57acc2950369e748548c446ac3e86de328 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 14 Nov 2026 04:03:51 +1100 Subject: [PATCH] fix(openshell): short random sandbox names the gateway accepts (#1864) --- internal/infrastructure/openshell/runtime.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/infrastructure/openshell/runtime.go b/internal/infrastructure/openshell/runtime.go index 4ba6ca3e6..108186170 100644 --- a/internal/infrastructure/openshell/runtime.go +++ b/internal/infrastructure/openshell/runtime.go @@ -5,6 +5,8 @@ package openshell import ( "context" + "crypto/rand" + "encoding/hex" "errors" "fmt" "log/slog" @@ -151,7 +153,10 @@ func (s *Sandbox) ExitDetail() string { // Acquire creates a sandbox running the agent l describes, and waits until it // is ready. func (r *Runtime) Acquire(ctx context.Context, l Launch) (*Sandbox, error) { - name := fmt.Sprintf("%s-agent-%d", r.instance, time.Now().UnixNano()) + name, err := sandboxName() + if err != nil { + return nil, err + } spec, err := r.spec(l) if err != nil { return nil, err @@ -170,6 +175,16 @@ func (r *Runtime) Acquire(ctx context.Context, l Launch) (*Sandbox, error) { return s, nil } +// sandboxName is a short random name: the gateway rejects names much longer +// than 19 characters, and the instance is carried by the sandbox's label. +func sandboxName() (string, error) { + var b [6]byte + if _, err := rand.Read(b[:]); err != nil { + return "", fmt.Errorf("name sandbox: %w", err) + } + return "archie-" + hex.EncodeToString(b[:]), nil +} + // Release stops watching s and removes its sandbox. func (r *Runtime) Release(ctx context.Context, s *Sandbox) { if s == nil {