Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func newRunCmd() *cobra.Command {
var noPostScript bool
var debugFilter string
var offline bool
var keepSandbox bool

cmd := &cobra.Command{
Use: "run <agent-name>",
Expand All @@ -62,7 +63,7 @@ func newRunCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
agentName := args[0]
printer := ui.New(os.Stdout)
return runAgent(cmd.Context(), agentName, fullsendDir, outputBase, targetRepo, fullsendBinary, envFiles, noPostScript, debugFilter, offline, printer)
return runAgent(cmd.Context(), agentName, fullsendDir, outputBase, targetRepo, fullsendBinary, envFiles, noPostScript, debugFilter, offline, printer, keepSandbox)
},
}

Expand All @@ -72,6 +73,7 @@ func newRunCmd() *cobra.Command {
cmd.Flags().StringVar(&fullsendBinary, "fullsend-binary", "", "path to a Linux fullsend binary to copy into the sandbox (default: current executable)")
cmd.Flags().StringArrayVar(&envFiles, "env-file", nil, "load environment variables from a dotenv file (repeatable)")
Comment thread
rh-hemartin marked this conversation as resolved.
cmd.Flags().BoolVar(&noPostScript, "no-post-script", false, "skip post-script execution (agent still runs full inference)")
cmd.Flags().BoolVar(&keepSandbox, "keep-sandbox", false, "skip sandbox deletion after the run (useful for post-failure inspection)")
cmd.Flags().StringVar(&debugFilter, "debug", "", `enable Claude Code debug logging with optional category filter (e.g. "api,hooks")`)
cmd.Flags().Lookup("debug").NoOptDefVal = "*"
cmd.Flags().BoolVar(&offline, "offline", false, "reject network fetches; only use cached remote resources")
Expand All @@ -81,7 +83,7 @@ func newRunCmd() *cobra.Command {
return cmd
}

func runAgent(ctx context.Context, agentName, fullsendDir, outputBase, targetRepo, fullsendBinary string, envFiles []string, noPostScript bool, debug string, offline bool, printer *ui.Printer) (runErr error) {
func runAgent(ctx context.Context, agentName, fullsendDir, outputBase, targetRepo, fullsendBinary string, envFiles []string, noPostScript bool, debug string, offline bool, printer *ui.Printer, keepSandbox bool) (runErr error) {
printer.Banner(Version())
printer.Blank()
printer.Header("Running agent: " + agentName)
Expand Down Expand Up @@ -366,6 +368,12 @@ func runAgent(ctx context.Context, agentName, fullsendDir, outputBase, targetRep
// Collect OpenShell logs before sandbox deletion for post-mortem debugging.
collectOpenshellLogs(sandboxName, runDir, printer)

if keepSandbox {
printer.StepWarn(fmt.Sprintf("Sandbox kept (--keep-sandbox): %s", sandboxName))
printer.StepInfo(fmt.Sprintf("openshell sandbox exec --name %s -- sh", sandboxName))
return
}

cleanupStart := time.Now()
printer.StepStart("Cleaning up sandbox")
if err := sandbox.Delete(sandboxName); err != nil {
Expand Down
Loading