chief icon indicating copy to clipboard operation
chief copied to clipboard

feat(config): configurable agent watchdog + bash command timeouts

Open Magentron opened this issue 7 months ago • 0 comments

Summary

Two related timeout knobs become configurable, so users can match Chief's safety nets to how their projects actually run:

  • agent.watchdogTimeout — silence threshold before Chief kills the agent process as hung. Default unchanged (5 minutes), now configurable. Bump this when acceptance criteria run long, quiet commands (integration test suites that produce no stdout for several minutes). "0s" disables the watchdog. Unparseable / negative values fall back to the default.
  • bash.timeout — maximum runtime for external bash commands invoked by Chief (currently worktree.setup). Empty / unset = no timeout (unchanged behaviour). Unparseable or negative values fall back to "no timeout" but surface a one-line warning in the worktree spinner so a typo isn't silently masked.

Both fields are Go duration strings ("30s", "5m", "1h"). Both are validated inline in the Settings TUI — invalid input is rejected with a clear error and the editor stays open so the user doesn't lose their value. Hand-edited config files with invalid values fall back to the documented default at runtime.

Also includes a small loop package cleanup: the test that exercises watchdog disable reads the live Loop via the internal map instead of GetInstance's defensive copy, so the assertion sees the actual runtime state. The GetInstance runtime-field omission contract is now documented.

Test plan

  • [ ] go test ./... passes
  • [ ] With agent.watchdogTimeout: "30m", an agent that pauses for ~10 minutes is not killed (was killed at 5m before)
  • [ ] With agent.watchdogTimeout: "0s", the watchdog is disabled and a hung agent is not killed
  • [ ] With bash.timeout: "10s" and a worktree.setup: "sleep 60", the setup is killed at ~10s
  • [ ] With bash.timeout: "" (default), worktree.setup runs to completion regardless of duration
  • [ ] In the Settings TUI, editing agent.watchdogTimeout to "not-a-duration" shows invalid duration "..." inline; editor stays open; valid value "20m" is accepted and persisted to .chief/config.yaml
  • [ ] Same flow for bash.timeout (incl. negative-rejection: "-10s" shows the negative-value error)
  • [ ] Hand-editing .chief/config.yaml with an invalid duration produces the documented warning in the worktree spinner (for bash.timeout) and falls back to the 5-minute default (for agent.watchdogTimeout)

Magentron avatar Apr 29 '26 21:04 Magentron