eval: a tool.bash call from a JS cell never resolves - no child, no auto-detach, 120 s timeout never fires; session idles until killed
Summary
A tool.bash call made from inside a JS eval cell never resolved. The child had no live process. Neither the eval foreground-detach notice (about 60 s) nor the call's own timeout: 120 ever produced anything. No tool result was ever written for the eval call. The session sat idle for about 68 minutes, until something outside stopped it (SIGTERM was not honoured within 10 s, so SIGKILL was used). The agent process was idle: every thread was parked in kevent64 / __psynch_cvwait. So this is an await that nothing will ever settle, not a busy loop or a blocked syscall.
Version: senpi 2026.11.5-1 (as bundled in omo-ai 5.1.64), macOS arm64, Bun runtime.
Reproduction (shape; no deterministic repro yet)
- Start a headless print-mode session (
omo -p "<prompt>" --model <anthropic model> --no-model-fallback --session-dir <dir>). Here the whole agent process ran under/usr/bin/sandbox-execwith a profile that denies file writes under one directory. Under that profile setuid binaries such as/bin/pscannot be exec'd (the shell reports 126). - In the first JS eval cell the model defines a helper and keeps reusing it in later cells:
const r = async (c) => (await tool.bash({ command: c, timeout: 120 })).text; - Eight earlier cells call
r(...)/tool.bash(...)and all return normally. That includes$(...)and<(...)substitutions,mktemp -d,bun install, and one call that ran past the foreground window and came back withCommand is still running; auto-detached to background with ID: bash_N (not killed; the original 120s timeout still applies). That background session finished about 0.4 s later. - The 9th cell is:
This is the first call in the session that names paths outside the workspace: bun's own bin dir, and a Linux-styleprint(await r("type -a bun; ls -la $(dirname $(command -v bun)) | head; cat /home/<user>/tmp/<dir>/logs/<file>.log 2>&1 | tail -20"));/home/...path. On macOS/homeis an autofs mount point, and that file does not exist there. Every part of it should finish in milliseconds. - Nothing comes back, ever.
Expected
- The
tool.bashcall resolves at or before its deadline: with output (here,type/lsoutput plus aNo such file or directoryline), or with a typed timeout or denial result at 120 s. - While a host tool call is in flight, the eval cell's foreground-detach window still applies, so the model gets a detached-cell result instead of silence.
- A child that exits is reaped. No zombie is left under the agent process.
- SIGTERM ends a session whose turn is parked in a tool call within the normal shutdown budget.
Actual
- The session transcript ends with the assistant
toolCallfor the 9theval(stopReason: toolUse). NotoolResultfollows it. There are no furthersession-lifecycleorwork-custodyentries, and no auto-detach notice. - Process state, inspected about 56 minutes after the call:
- The agent process used 0.0 % CPU. Its only child was one zombie (
<defunct>) that had existed since session start (its pid was assigned during startup). There was no live child for the hung bash call. sampleover 2 s: all threads idle (kevent64/__psynch_cvwait), including theWorkerthread that hosts the JS eval kernel. The main thread was idle too.- The session's parent held a local unix socket listening for test-runner requests. It had no accepted connection, so the stalled command was not waiting on any outside service.
- The agent process used 0.0 % CPU. Its only child was one zombie (
- It was stopped at about 68 minutes. SIGTERM did not end the process within 10 s, and SIGKILL did.
Evidence (trimmed transcript entry shapes, identifiers stripped)
18:20:00Z assistant toolCall eval r("... ; bun run test-ids > <tmp>/ti.log 2>&1; ...")
18:21:00Z custom work-custody {source: terminal-background-sessions, activeCount: 1, items: [bash_16]}
18:21:00Z toolResult eval "Command is still running; auto-detached to background with ID: bash_16 (not killed; the original 120s timeout still applies). Partial output: ..."
18:21:00Z custom work-custody (bash_16 finished)
18:21:06Z assistant toolCall eval tool.bash({ command: "<export ...>; bun test --timeout 30000 <paths>", timeout: 900 })
18:21:34Z toolResult eval (returned, ~28 s)
18:21:40Z assistant toolCall eval r("ls packages/*/test/ | grep ...")
18:21:40Z toolResult eval (returned)
18:21:43Z assistant toolCall eval tool.bash({ command: "<export ...>; bun test --timeout 30000 <8 files>", timeout: 900 })
18:22:14Z toolResult eval (returned, ~31 s)
18:22:19Z assistant toolCall eval r("type -a bun; ls -la $(dirname $(command -v bun)) | head; cat /home/<user>/tmp/<dir>/logs/<file>.log 2>&1 | tail -20")
<end of transcript: no toolResult, no lifecycle change, for ~68 min>
The full transcript is held locally. It comes from a private repository and is not attached.
Hypotheses (labelled; not proven)
- H1 (favoured by the timers): the call parked before execution. Neither the 60 s auto-detach notice nor the 120 s timeout fired, and no child existed for this call. Both of those suggest the bash executor never armed its timers, i.e. the call never reached spawn. It is the first call in the session that names out-of-workspace paths (
/home/..., an autofs mount point on macOS, plus bun's bin dir). So candidates are the per-segment permission/external-path evaluation (cf. #4317, #1416) or an approval request that has no surface in a headless-psession (cf. #2512), awaited with no deadline. - H2: the child spawned, exited and was reaped, but its exit / output-stream close was never observed by the bash tool while the eval bridge awaited it. The per-call timeout did not fire because it hangs off that same unobserved event.
- Either way, the eval side has no independent deadline on an in-flight host tool call. One stalled
tool.bashtakes the eval cell, the turn and the session with it, and the session also stops honouring SIGTERM. - The pre-existing zombie child may or may not be related (for example, a setuid exec refused by the sandbox at startup that was never reaped). It is worth checking which startup spawn produced it.
Acceptance criteria
- A
tool.bashcall from an eval cell always settles at or before itstimeout, wherever it stalls (dispatch, permission/approval, spawn, stream close), with output or a typedtimeout/deniedresult. - In print mode, the eval foreground-detach window applies while a host tool call is in flight.
- A permission approval that has no surface (headless
-p) settles at once as a typed denial and never waits. - Every child of the agent process is reaped after it exits. No
<defunct>child survives under a live session. - SIGTERM ends a session parked in a tool call within the shutdown budget.
- A regression test reproduces the confirmed stall point (eval cell ->
tool.bashnaming an out-of-workspace / autofs path, in print mode) and fails on the current code.
Related: #2512, #1416, #4317, #2265, #6167 / #6168 (eval nested tool updates, merged after this version).
Triage update: lead hypothesis refuted, stall point not pinned yet
I traced this against main at d2225ca510 and the held transcript (evidence held locally). Short version: the approval-routing theory does not fit this session, and the transcript alone can't tell us whether the 9th eval cell ever started. No fix PR yet, because any fix chosen now would be a guess.
Cluster
| Item | State | Relation |
|---|---|---|
| #2512 / #2516 | closed / merged | Approval request emitted to host stdout from a reused eval kernel. Fixed by the dispatch-context snapshot (senpi-codemode/src/tool/cell-handler.ts:99), which is in 2026.11.5-1. Same symptom shape, different mode. Not a duplicate. |
| #1416 / #1419 | closed / merged | A sync external-dir walk blocks the main thread on autofs /home. Same class as H4 below. |
| #4317 | merged | Per-segment bash permission evaluation. This is where the bash call's external_directory request comes from. |
| #2265 | open | Pending tool calls never settle after the host dies. Separate cause (host loss), same "no deadline on an in-flight call" family. |
| #6167 / #6168 | closed / merged | Nested tool live updates. Merged after this version, unrelated to settling. |
Hypothesis: approval request misrouted, call waits forever before spawn. Refuted for this session.
- The reviewer ran as a print-mode session (
omo -p ... --no-model-fallback --session-dir ...). It was not an RPC client, and no permission preset orpermissionrule was set in any layer (argv, global or project settings), so the defaultfull-accesspreset applied. The 9th command'sbashandexternal_directoryrequests are therefore decidedallowand nothing is asked. - Even when something is asked, print mode has
ctx.hasUI === false.permission-system/index.ts:401-410then answers synchronously throughhandleNoUI(a typed refusal), so the call cannot wait on an approval card. - For a bash call,
PermissionService.askhas noawaitbefore it registers the pending request (identityWantedis false forbash/external_directory). The synchronousisPendingcheck atindex.ts:385therefore sees the request, and the no-UI branch replies to it.
What the code does establish
- The bash deadlines are armed only after spawn.
terminal/tools/bash.ts:265awaitsspawnCommandSessionbefore either timer exists (:296kill grace,:313detach gate). Preflight (tool_callhooks and permission) also runs beforeexecute. So "no child + no detach + no 120 s timeout" means only "it parked beforeexecutereached spawn". It does not name where. - The cell's own 1800 s hard limit was not observed either. That timer is armed when the cell is created (
senpi-codemode/src/tool/cell-deadlines.ts:42). It cancels a foreground cell throughCellExecution.wait(cell-execution.ts:128), and the interrupt grace there is bounded, so a stuck bridge promise cannot hold it. The session idled for ~68 min with no eval result written. That leaves three possibilities: the cell never started, its result never reached the transcript, or the main JS thread was not running. - Every model-issued tool call awaits the agent event queue with no deadline before preflight (
agent-session.ts:2419->:2448). The transcript persisted the 9th assistanttoolCalland nothing after it, with no lifecycle or custody entry.
Remaining labelled hypotheses (none proven)
- H3: wedged agent event queue. One queued handler (for example
tool_execution_startprocessing for the eval call) never settles. Then the eval's preflight waits forever: no cell, no hard-limit timer, no bash, no child. Even a cell result produced later would never persist, because persistence runs on the same queue. This fits every observation. The nested path already avoids exactly this wait (agent-session.ts:2567, comment "could wait on the caller's own tool_execution_start processing"). - H4: the main thread blocked synchronously in the external-dir walk.
permission-system/external-dir.ts:48,71runslstat/staton the main thread over the/home/...path (autofs on macOS). This would explain the dead timers and the ignored SIGTERM. Against it: the reported thread sample shows every thread inkevent64/__psynch_cvwait, not in a stat syscall, and a probe today on the same host returnedENOENTfor that path in about 14 ms (/homecurrently not mounted).
Evidence that would settle it (missing)
- Proof of whether the 9th cell started: any
tool_execution_starthandling for the eval call, or kernel-side output. The transcript cannot show this, because the same queue writes it. - A native stack (
sample <pid> 5) of the engine process itself, taken while hung. The recorded pid file names the review launcher, and it is not certain which process was sampled. Also needed: its main-thread frames and aps -o pid,ppid,statof its process group. - A JS-level async stack or heap snapshot of the hung engine, or a session-logger trace with queue enqueue/settle markers. The process was SIGKILLed, so none of this survives.
Next step: add cheap instrumentation, then capture the bullets above on the next occurrence. The instrumentation is a deadline-bounded warning when preflight's event-queue wait or an eval host call exceeds its owner's timeout. Once the stall point is pinned, a RED test plus fix will follow under this issue.
Instrumentation for the next occurrence: #6192 (draft) logs one session-log warning when a tool call's event-queue wait, its tool_call/permission preflight, or a bash spawn outlives 30 s (or the call's shorter timeout), naming the call and the queue head; no behaviour change.
Instrumentation for this hang landed: #6192 merged into main as 41686cc7582ad625f61d8abc45121e245683675e (Part of #6189, no behaviour change). The next occurrence now writes one of these warnings to the session log (<agent dir>/logs/session.log) naming where the call stalled:
tool_call_event_queue_stalled(event-queue wait before a tool call; call id, tool, queue depth, oldest pending item, elapsed)tool_call_preflight_stalled(tool_call hooks incl. the permission decision; parent call id for eval-cell calls)bash_spawn_stalled(a bash spawn that never returns)
When it happens again, please capture the session log tail plus a native sample of the ENGINE process before killing it, and attach them here. Keeping this issue open until the root cause is fixed.
Step 1 (engine additive) merged: #6204 -> main 920a085089. It adds the persisted mode entry, the effective-mode echo (permissionPreset / permissionPresetSource / permissionPresetStatus) on open/get_state, the set_permission_preset record (cap set_permission_preset_v1), the change event and the raise API; no default changes. Evidence: review CLEAR at the exact head, whole-suite receipt green on Linux, EQ green on darwin-arm64. Step 2 (#6206, the delegated default flip) is in its security-review fold; step 3 (omo runners) follows. This issue stays open until step 3 runs on the remote host.
Step 2 (behaviour flip) merged: #6206 -> main 5b6943e7e6. Delegated or engine-started work on a session with no named mode now runs as ask; a client-named mode or launch flag always wins; children inherit and follow the parent's mode; the embedder host default is recorded as host_default; S-H1 (preset-less reattach) and S-H2 (every delegated drive/device_admin record marks the session remote-driven) fixed. Evidence: review CLEAR at the exact head, whole-suite receipt green on Linux, EQ green on darwin-arm64. Step 3 (omo runners: child dialog forwarding, live-follow, --permission-preset spawn arg, and the senpi pin) must ship in the same omo release; this issue stays open until step 3 runs on the remote host.
Filed a data point for this: 17 tool_call_preflight_stalled warnings, all on in-process subagent children at their first tool call; the read-call cases pin the stall to the tool_call hooks stage → #6670
Follow-up on the child-stall family, with something better than more host data: a webui-free minimal reproducer, what it rules out, and where the surviving fault has to live. This also supersedes the break-point hypothesis in my last #6670 comment — the "open_session profile path never populates activePreset" theory is dead; details below.
The reproducer
Spawn the engine exactly as an embedder does — @code-yeongyu/senpi CLI bundle + the omo-senpi plugin + --mode rpc --multi-session over stdio, via the official RpcClient from the same package. No webui, no custom host code. Then: open_session with permissionPreset: "full-access", one prompt that spawns a subagent_type: explore child to read one in-workspace file.
// repro-child-mode-inherit.mjs — node >= 20; run inside a dir whose node_modules has @code-yeongyu/senpi
import { RpcClient } from "@code-yeongyu/senpi";
import { readFileSync, existsSync, readdirSync, statSync } from "node:fs";
import { join } from "node:path";
const PROJECT = "/your/project"; // <- any workspace project with a default model
const CHILD_ROOT = `${process.env.HOME}/.omo/agent/projects/<project-hash>/senpi-task/children`; // <- hash dir of PROJECT
const PROMPT = "Call the task tool first: subagent_type=explore, prompt=read /your/project/package.json and report only the name field. No other tools.";
const client = new RpcClient({
cliPath: "/path/to/node_modules/@code-yeongyu/senpi/dist/bundle/cli.js",
args: ["--extension", "/path/to/node_modules/omo-ai/plugin", "--multi-session"],
cwd: PROJECT,
env: { OMO_CODING_AGENT_DIR: `${process.env.HOME}/.omo/agent`, OMO_NATIVE: "1" },
});
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const send = (m) => client.send(m);
await client.start();
await client.setClientInfo(80, []);
for (let i = 0; i < 20; i++) { try { if ((await send({ type: "get_protocol_info" })).success) break; } catch {} await sleep(1500); }
const open = await client.openSession({ permissionPreset: "full-access" }); // the surface your docs expose
console.log("open:", open.state?.sessionId);
const start = Date.now() - 2000;
await client.prompt(PROMPT);
for (let i = 0; i < 25; i++) {
await sleep(4000);
const fresh = [];
if (existsSync(CHILD_ROOT)) for (const d of readdirSync(CHILD_ROOT)) {
const sdir = join(CHILD_ROOT, d, "sessions");
const walk = (dir) => { if (!existsSync(dir)) return;
for (const e of readdirSync(dir, { withFileTypes: true })) {
const p = join(dir, e.name);
e.isDirectory() ? walk(p) : e.name.endsWith(".jsonl") && statSync(p).mtimeMs > start && fresh.push(p);
} };
walk(sdir);
}
if (fresh.length) {
const txt = readFileSync(fresh[0], "utf8");
console.log("child session file:", fresh[0]);
console.log("carries permission_mode entry:", txt.includes('"permission_mode"')); // observed: false
process.exit(0);
}
}
Observed on senpi 2026.11.10-2 (the bundle an embedder ships) + omo plugin, same machine as the earlier A/B: the child's session file contains no permission_mode entry — the child's open carried no preset — and ~30 s later the engine logs tool_call_preflight_stalled for that child's first read. Same symptom on 2026.11.15-2 via our webui host and via an interactive session on another project (both children bare, both stalled). One unrelated footnote: this engine+plugin combo prints thread gateway: Gateway schema 14 is newer than this binary's supported version 11 on stderr at startup; it doesn't gate the repro.
What this rules out
Three variants, same spawn shape, child bare in all of them:
| Variant | What it exercises | Child preset |
|---|---|---|
A. open_session { permissionPreset } |
the client-named mode at open | bare |
B. set_permission_preset first (returns success), child spawned after |
the flag-set + announce path (agent-session-runtime.ts setPermissionPreset()) |
bare |
C. parent performs a read itself before spawning |
forces the permission-system to attach and load rules (reader registered) before the spawn | bare |
(For B, the child in question was the parent's own relaunch of its stalled first child — spawned after set_permission_preset had succeeded.)
Together with the engine-level --permission-preset launch flag already known to fail (delegatedPreset() in permission-decision.ts returns "ask" when launchFlagNamed() — a launch flag cannot rescue delegated work), every preset-application surface we can reach leaves the child bare in this host shape.
The discriminating fact
The TUI (single-process interactive, same binaries, same machine, same file) inherits — its children carry the mode and complete in seconds with no dialog. The failure is specific to the multi-session RPC worker shape (--mode rpc --multi-session over stdio). That is also, we suspect, why the scripted-model repro on the interactive path didn't hit it.
Where the surviving fault has to live (main @ 6d4426a, 2026-11-20)
Static reading says the reader should always answer, which is the interesting part:
packages/omo-senpi/src/components/task/child-parent-wiring.ts—parentPermission.current()ispi.getPermissionPreset?.().- The extension API impl (compiled
core/extensions/loader.js) —getPermissionPreset()resolvesruntime.createContext().sessionManager, thenreadPermissionPreset(sessionManager)= areaders3.get(sessionManager)lookup (a silent catch returnsundefinedwhencreateContext()has no session). permission-system/index.tsregisters that reader at attach undercontextKey(ctx)=ctx.sessionManager ?? runtimeKey, returning the in-memoryactivePreset.permission-system/settings.tspickPermissionPreset()falls back toDEFAULT_PERMISSION_PRESET— so once the permission system has loaded for the session,activePresetis never null.agent-session-runtime.tssets thepermission-presetflag on both the open path (apply()) and the later-move path (setPermissionPreset()).
So statically: attach + load → reader registered and non-null → current() returns a preset → child carries it. Empirically in the worker: current() yields undefined at spawn time (bare child), after a successful set_permission_preset, and after the parent's own gated read forced an attach. The only surviving explanation we can see is an identity split inside the worker: the sessionManager that getPermissionPreset()'s createContext() resolves is not the object the permission system attached and registered its reader under (or the equivalent stale-runtime-closure split), in the multi-session worker isolate. That is not distinguishable from outside the process — it needs one instrumented run on your side, or a key-identity log at both sites.
Alternatively, a fix that bypasses the question entirely: the delegated-child spawn could read the parent's persisted client preset (persistedClientPreset, the permission_mode session-file entry — present and verified in our parent files) instead of pi.getPermissionPreset().
Happy to attach the raw child session files (bare, both versions), the parent session files showing the applied client mode, the host warning lines, or the three probe scripts verbatim.
Likely root cause for this hang, now confirmed on four freezes of the same shape: #7150. A command naming a /home/<user>/... path makes the external_directory decision list /home with readdirSync on the engine's main thread, and on macOS that open blocks on the autofs trigger. A native sample of a frozen engine has the main thread in NodeJSFSPrototype__readdirSync -> openat$NOCANCEL for 100 % of samples. That is H4 here, with the blocking call being readdir (an open(2)) rather than lstat. The 9th cell in this report named exactly such a path.
Data point for this family: code-yeongyu/senpi#7157. Long-running engines on macOS were found with all Bun pool threads parked in realpath -> openat on the /home automount. Every abandoned deadline-raced fs call keeps its thread, and once the pool is gone every async fs call in the engine hangs while the event loop (and the elapsed timer) keep running. A tool.bash from an eval cell naming a /home/... path was again the trigger in the latest occurrence.
Cross-link: a user report of the same visible symptom (the agent stops watching a running command mid-way) is tracked in code-yeongyu/senpi#7682, which lists every mechanism that produces it. This issue stays the home of its own mechanism.
Friendly ping on the webui-free minimal reproducer comment above (Nov 20): the child-mode-inheritance failure in the multi-session RPC worker is one more "await that never settles" mechanism, and it is not in #7682's list yet. The reproducer there is a single paste-and-run script; happy to re-test against any current main if that helps triage.