[idea] Resume agents with their original launch flags (--dangerously-skip-permissions, --model, …) after a restart #632
Replies: 4 comments
|
+1 — and this also fixes harness forks, not just flags. A fork/renamed build that reports as its parent agent (e.g. So this generalizes cleanly from "preserve flags" to "preserve the actual binary," and covers the fork case for free. Strong +1 — happy to test the fork path against your implementation. |
|
+1 — hit exactly this. I launch claude --dangerously-skip-permissions --disallowedTools "Bash(rm:*)" ...; after a reboot the resumed pane drops back to default permission mode and loses the dangerous-command denylist — a real safety regression, not just convenience (losing --model). Replaying launch_argv fixes both. Today's workaround is moving the rules into ~/.claude/settings.json, which works but is a second place to manage and easy to forget on resume. Happy to test the PR on macOS / Claude Code. |
|
Try this branch if you’re interested in this feature: https://github.com/iosmanthus/herdr/tree/release-20260622 |
|
Another data point, a workaround that works today, and a possibly even smaller native shape than replaying I run Claude Code panes as # herdr types `claude --resume <id>` into the pane shell on restore
claude() {
if [[ -n "$HERDR_ENV" && "$1" == "--resume" ]]; then
command claude --dangerously-skip-permissions "$@"
else
command claude "$@"
fi
}It works, but it's zsh-only, copy-pasted per agent, and it leans on resume being typed into a shell — if that ever becomes a direct spawn, it breaks silently. Given #1080 drew the boundary at "no process/launch tracking", maybe the minimal native shape is neither replay nor derivation, but a static config override of the per-agent resume template in [session.resume_commands]
claude = ["claude", "--dangerously-skip-permissions", "--resume", "{session_id}"]
codex = ["codex", "--dangerously-bypass-approvals-and-sandbox", "resume", "{session_id}"]Still fully declarative: nothing tracked or parsed, the session ref stays data substituted into one argv slot, and agents without an override behave exactly as today. It also covers the fork-binary case above (point the template at |
Uh oh!
There was an error while loading. Please reload this page.
idea / problem
When herdr restarts and resumes a native agent session, it rebuilds the command as just
<agent> --resume <id>and drops every flag the pane was launched with. A pane I started asclaude --dangerously-skip-permissions --model opuscomes back as plainclaude --resume <id>— so I get re-prompted for permissions and lose--model. herdr already records the original command inlaunch_argvand persists it in the session snapshot; the resume path just doesn't use it.requested change
When a pane has a recorded
launch_argv, replay that original command and append the agent's resume reference, instead of rebuilding from scratch:How it works:
--resume/-r,--continue/-c, codex'sresumesubcommand — so the replayed command can never carry two conflicting selectors. (codex's-c/--configis intentionally left alone — it isn't--continue.)<agent> --resume <id>when there's no recorded launch command (e.g. agents detected from a hand-typed shell).launch_argvonto the resumed terminal so the flags survive repeated restarts, not just the first.Like the auto-hibernation idea, this is mostly an automatic use of primitives herdr already has (
launch_argvcapture + deferred resume) rather than new machinery.I have a working implementation (
src/agent_resume.rs+src/persist/restore.rs, with unit tests across the supported agents) and can open a PR if this direction is welcome.All reactions