kshitijk4poor
6f8975dcd8
fix(tools): don't compound-rewrite spawn_via_env background wrappers
...
Background tasks on non-local backends (SSH/Docker/Modal/Daytona/Singularity)
go through `ProcessRegistry.spawn_via_env`, which builds a hand-crafted,
shell-safe wrapper:
mkdir -p T && ( nohup bash -lc CMD > LOG 2>&1; rc=$?; ... ) & echo $! > PID && cat PID
`BaseEnvironment.execute()` unconditionally ran `_rewrite_compound_background`
on every command, including this wrapper. The rewrite (meant to defuse the
`A && B &` subshell-wait trap for user commands) turns `( ... ) & echo $!` into
`{ ( ... ) & } echo $!` — note `} echo` with no separator, which is a bash
syntax error. The wrapper then never produces a PID, the redirected output file
is never created, and the agent sees an immediate exit code -1. This breaks
*every* background launch on a non-local backend (e.g. a simple
count-and-redirect script over SSH), not just edge cases.
Fix:
- Add `rewrite_compound_background: bool = True` to `BaseEnvironment.execute()`
(and the `BaseModalExecutionEnvironment` override, which accepts and ignores
it). Default preserves existing behavior; the user foreground terminal path
still rewrites.
- `spawn_via_env` passes `rewrite_compound_background=False` so its already
shell-safe wrapper is left intact.
- Treat a wrapper that produces no PID as a failed launch (mark the session
exited with a real exit code instead of exposing a fake running session), and
don't register/checkpoint a session that never started.
Verified empirically: with the rewrite skipped, the wrapper is valid bash,
launches the process, captures the PID, and writes the log/pid/exit files; the
old rewritten form fails `bash -n` with a syntax error.
Based on #33756 by @CharZhou (extracted from a multi-feature branch; the
unrelated image_gen / docker-media changes are not included here).
Co-authored-by: CharZhou <17255546+CharZhou@users.noreply.github.com>
2026-06-01 00:05:10 +05:30
..
2026-05-22 03:33:01 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-12 15:14:49 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 15:43:55 +10:00
2026-04-24 03:46:46 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-09 13:35:39 -07:00
2026-05-29 03:58:56 -07:00
2026-05-28 22:26:25 -07:00
2026-05-30 07:31:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-04-26 09:57:58 -07:00
2026-05-06 03:41:21 -07:00
2026-05-28 22:26:25 -07:00
2026-05-22 19:46:18 -07:00
2026-05-07 05:38:05 -07:00
2026-04-30 20:33:33 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-17 02:29:41 -07:00
2026-05-29 03:44:49 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-21 17:38:19 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-08 14:55:40 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 11:49:54 +10:00
2026-05-07 06:17:49 -07:00
2026-05-25 12:24:58 +10:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:09 -07:00
2026-05-29 03:44:49 -07:00
2026-05-30 07:01:22 -07:00
2026-05-30 14:38:30 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-04-23 15:11:52 -07:00
2026-05-28 22:26:25 -07:00
2026-05-30 07:55:36 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-30 06:25:50 -07:00
2026-05-28 03:27:20 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-21 16:40:04 +05:30
2026-05-15 01:33:13 -07:00
2026-04-23 03:01:18 -07:00
2026-04-28 22:16:08 -07:00
2026-05-30 07:28:11 -07:00
2026-05-18 21:01:14 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 01:48:08 -07:00
2026-05-04 15:31:47 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-30 07:58:08 -07:00
2026-05-29 22:26:24 +05:30
2026-05-28 22:26:25 -07:00
2026-05-30 07:58:08 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-04-29 20:05:32 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-16 13:06:56 -07:00
2026-05-07 05:35:33 -07:00
2026-05-28 22:26:25 -07:00
2026-05-15 14:00:01 -07:00
2026-05-07 07:08:04 -07:00
2026-05-30 02:08:29 -07:00
2026-05-15 14:00:01 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-07 07:03:21 -07:00
2026-05-28 22:26:25 -07:00
2026-05-08 09:27:26 -07:00
2026-05-08 09:27:26 -07:00
2026-04-23 15:14:11 -07:00
2026-05-28 22:26:25 -07:00
2026-05-27 00:43:32 -07:00
2026-05-28 22:26:25 -07:00
2026-04-22 14:45:50 -07:00
2026-05-25 15:18:45 -07:00
2026-05-20 01:46:40 -05:00
2026-05-25 06:13:36 -07:00
2026-06-01 00:05:10 +05:30
2026-05-13 17:32:22 -07:00
2026-05-28 22:26:25 -07:00
2026-05-18 10:37:35 -07:00
2026-05-28 22:26:25 -07:00
2026-05-24 18:05:33 -07:00
2026-05-18 22:19:50 -07:00
2026-05-30 02:39:08 -07:00
2026-05-17 23:28:45 -07:00
2026-04-26 11:55:02 -07:00
2026-05-28 22:26:25 -07:00
2026-05-17 02:29:41 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 12:24:39 -07:00
2026-05-19 14:17:38 -07:00
2026-05-28 01:42:19 -07:00
2026-05-29 12:24:39 -07:00
2026-05-30 02:05:10 -07:00
2026-05-27 00:43:32 -07:00
2026-04-29 21:56:47 -07:00
2026-04-24 07:06:11 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 16:07:15 +10:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 11:49:54 +10:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-09 14:46:34 -07:00
2026-05-27 00:43:32 -07:00
2026-04-30 20:38:09 -07:00
2026-05-25 14:52:24 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 13:35:39 +10:00
2026-05-31 00:50:19 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 02:04:12 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 13:24:12 -07:00
2026-05-25 01:41:19 -07:00
2026-05-29 13:24:12 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-15 12:11:32 -07:00
2026-05-13 17:32:22 -07:00
2026-05-28 22:26:25 -07:00
2026-05-29 13:24:12 -07:00
2026-05-18 22:29:45 -07:00
2026-05-25 05:15:55 -07:00
2026-05-28 22:26:25 -07:00
2026-05-24 18:04:54 -07:00
2026-05-13 22:04:28 -07:00
2026-05-25 14:30:06 -07:00
2026-05-18 10:51:15 -07:00
2026-05-28 22:26:25 -07:00
2026-05-13 16:39:41 -07:00
2026-05-13 16:39:41 -07:00
2026-05-29 22:26:24 +05:30
2026-05-31 00:12:09 -07:00
2026-05-30 01:40:39 -07:00
2026-05-28 22:26:25 -07:00
2026-05-31 00:11:52 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 04:52:42 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 04:52:42 -07:00
2026-05-29 04:00:00 -07:00
2026-05-30 07:58:08 -07:00
2026-05-28 04:52:42 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-28 22:26:25 -07:00
2026-05-21 02:38:45 +05:30
2026-05-25 03:35:33 -07:00
2026-05-28 22:26:25 -07:00