Skip to content

fix(agent): bound shell execution and show quiet command progress - #1378

Merged
AnthonyRonning merged 3 commits into
masterfrom
fix/agent-runaway-shell
Oct 30, 2026
Merged

AnthonyRonning merged 3 commits into
masterfrom
fix/agent-runaway-shell

Conversation

@w3irdrobot

@w3irdrobot w3irdrobot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

A model-generated command changed into /tmp and searched ../../, reaching the filesystem root and blocking on AppArmor's revision interface. The saved checkout and working-directory propagation were correct. There was no default command deadline, and the live timeline discarded progress updates.

This fix lives entirely in Maple. The Pi directories are unchanged. Maple wraps the existing BashOperations interface and owns the live status updates.

  • Shell commands start in the task's saved folder. Maple validates that folder and tells the model to use explicit checkout paths for repository searches. No new workdir tool argument is added.
  • The default deadline is 30 minutes to allow slow builds; a call can request longer. Search guidance asks for an explicit short timeout, normally 30 seconds.
  • The deadline covers setup, command delivery, and execution. Stop/deadline signals cancellation through Pi's existing process cleanup, with at most one second of cleanup grace before dropping an unresponsive operation.
  • Quiet commands show their starting folder, elapsed time, time since output, deadline, and Stop reminder every five seconds, including on collapsed cards.
  • Completion and progress publication share a lock. Late output and heartbeat updates cannot return a completed shell call to running, and the run-owned heartbeat task is stopped and joined at run completion.

Regression tests live in Maple and cover saved worktrees across cold loads, invalid working directories, explicit deadline overrides, blocked pipeline cancellation/deadline/drop, unresponsive operations, retained output, and late-update ordering. They use disposable directories and FIFOs, without scanning / or reading blocking kernel interfaces.

Background execution with polling, waiting, and stopping is tracked separately in #1380.

Validation on this revision (pinned Nix environments, local disposable fixtures):

  • Full Agent just ci passed: formatting, packaging/Git metadata fixtures, all Clippy feature sets, dependency checks, workspace tests, all-target build, and headless tests (351 passed, 2 ignored).
  • Focused Maple shell adapter, saved-worktree/cold-load, quiet progress/Stop, timeline ordering, and stale-update/heartbeat regressions passed.
  • Root nix flake check --no-update-lock-file --print-build-logs passed all seven Linux checks.
  • Verified zero diff against the PR base in all three Pi directories and crates/UPSTREAM.md.

These safeguards do not sandbox shell commands or rewrite search expressions. Commands can still change directories, and deliberately detached processes can escape Unix process groups. Native macOS/Windows runtime behavior and packaged-app smoke remain unverified locally; ci:windows remains on this PR. No live service, AppArmor policy, credentials, pairing, or application state was changed.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@w3irdrobot w3irdrobot added the ci:windows Run Windows checks on this PR label Oct 29, 2026
@w3irdrobot
w3irdrobot marked this pull request as ready for review October 29, 2026 22:49
@AnthonyRonning

Copy link
Copy Markdown
Contributor

Good catch, yeah we should definitely have something here. However, unless there is a critical reason otherwise, I have a strict rule that should be documented somewhere about not touching the pi subdirs. See if you can add a bounded thing without that. I think the longer term solution here is to do what I've seen other agents do which is moving tasks to the background and add polling, waiting, and shell killing capabilities around long shell commands.

@w3irdrobot

Copy link
Copy Markdown
Contributor Author

Updated this to keep all Pi directories unchanged. The timeout and progress handling now live in Maple using the existing operations hook. Kept the 30-minute default with longer timeouts allowed, and fixed the completion race. Background execution with poll/wait/stop is tracked in #1380. Local CI passes.

@AnthonyRonning AnthonyRonning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 0a48340: Maple-only wrapper with the Pi directories unchanged, CI green. Merging as the interim fix; background jobs remain in #1380. One test-only nit for a follow-up: on macOS with TMPDIR under /tmp, quiet_shell_reports_effective_folder_deadline_and_idle_time_until_stop compares the raw tempdir path against the canonical /private/tmp/... cwd, so it should compare canonicalized paths.

@AnthonyRonning
AnthonyRonning merged commit 3c3bb67 into master Oct 30, 2026
23 checks passed
@AnthonyRonning
AnthonyRonning deleted the fix/agent-runaway-shell branch October 30, 2026 06:15
AnthonyRonning added a commit that referenced this pull request Oct 30, 2026
The quiet-shell test from #1378 compared the folder the shell reports
with the temporary project path as given. The session works in the
project's canonical path, so the test failed wherever the temporary
folder is behind a symbolic link, as `/tmp` is on macOS. That includes
the pre-commit hook inside the Nix shell. It now compares the canonical
path, as the other project-root tests do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:windows Run Windows checks on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants