← Back to PRs

#15378: feat(exec): support `background: false` to force synchronous execution

by TorbenWetter open 2026-02-13 11:01 View on GitHub →
agents size: XS
## Summary - Gives `background: false` an explicit meaning: **force synchronous execution**, suppressing the yield timer entirely - Previously `false` was a no-op (treated the same as omitting the parameter) — no backwards-compatibility impact - Adds a test verifying synchronous completion even with an aggressive `backgroundMs: 10` ### Semantics after this change | Value | Behavior | |---|---| | `background: true` | Immediate background (unchanged) | | `background: undefined` | Timer-based auto-background via `yieldMs`/`backgroundMs` (unchanged) | | `background: false` | **Synchronous — no yield timer, blocks until completion (new)** | ## Motivation I'm building [agentpass](https://github.com/TorbenWetter/agentpass), a security gateway that mediates AI agent requests to Home Assistant through human approval on Telegram. The `agentpass request` CLI command blocks for up to 15 minutes while waiting for the guardian to approve or deny. With the current exec tool, the default 10-second yield timer backgrounds these commands prematurely, causing the agent to announce intermediate status messages instead of waiting silently for the result. Neither `yieldMs` (clamped to 120s) nor globally raising `backgroundMs` solve this cleanly — you'd need per-command control. `background: false` is the natural inverse of `background: true` and gives skills exactly that control. ## Implementation When `background: false` is passed, `yieldWindow` is set to `null` — the same value used when `allowBackground` is globally disabled. This means no `setTimeout` race is created, and the code falls through to the synchronous `run.promise.then(...)` path. ## Test plan - [x] New test: `"forces synchronous execution with background=false"` — creates an exec tool with `backgroundMs: 10`, runs a command with `background: false`, asserts `status === "completed"` (not `"running"`) - [x] All 22 existing tests in `bash-tools.test.ts` and `bash-tools.exec.background-abort.test.ts` still pass - [x] `pnpm build && pnpm check` passes (oxfmt, tsgo, oxlint — 0 warnings, 0 errors) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates the `exec` agent tool to give `background: false` explicit semantics: it disables the yield/background timer entirely and forces the tool call to wait for command completion. The change is implemented by treating `background === false` as a request for synchronous execution (`yieldWindow = null`), which skips the `setTimeout` yield race and falls through to the existing `run.promise.then(...)` completion path. A new unit test is added to `bash-tools.test.ts` to ensure a command completes synchronously even when `backgroundMs` is configured aggressively low (10ms). Existing `background: true` and timer-based yield behavior (`yieldMs`/`backgroundMs`) are unchanged. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - The change is narrowly scoped (only affects yield-timer selection) and is covered by a targeted new unit test. The synchronous path already exists; this PR just makes it reachable via an explicit parameter. No additional callsites or side effects were introduced in the reviewed code. - No files require special attention <sub>Last reviewed commit: 461484b</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs