autonomy policy: add configurable idle_round_budget auto-release window for no-dialog execution

This commit is contained in:
DBT
2026-03-01 16:08:26 +00:00
parent ed47e2dfe0
commit 5f9d526ef4
5 changed files with 23 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ type Options struct {
QuietHours string
UserIdleResumeSec int
WaitingResumeDebounceSec int
IdleRoundBudgetReleaseSec int
MaxRoundsWithoutUser int
TaskHistoryRetentionDays int
AllowedTaskKeywords []string
@@ -111,6 +112,9 @@ func NewEngine(opts Options, msgBus *bus.MessageBus) *Engine {
if opts.MaxRoundsWithoutUser < 0 {
opts.MaxRoundsWithoutUser = 0
}
if opts.IdleRoundBudgetReleaseSec < 0 {
opts.IdleRoundBudgetReleaseSec = 0
}
if opts.TaskHistoryRetentionDays <= 0 {
opts.TaskHistoryRetentionDays = 3
}
@@ -302,8 +306,15 @@ func (e *Engine) tick() {
continue
}
if st.BlockReason == "idle_round_budget" && e.opts.MaxRoundsWithoutUser > 0 && e.roundsWithoutUser >= e.opts.MaxRoundsWithoutUser {
// Stay waiting until user activity resets round budget.
continue
// Optional auto-release without user dialog: allow one round after configured cooldown.
if e.opts.IdleRoundBudgetReleaseSec > 0 && !st.WaitingSince.IsZero() && now.Sub(st.WaitingSince) >= time.Duration(e.opts.IdleRoundBudgetReleaseSec)*time.Second {
e.roundsWithoutUser = e.opts.MaxRoundsWithoutUser - 1
e.writeReflectLog("resume", st, fmt.Sprintf("autonomy auto-resumed from idle round budget after %ds", e.opts.IdleRoundBudgetReleaseSec))
e.writeTriggerAudit("resume", st, "idle_round_budget_auto_release")
} else {
// Stay waiting until user activity resets round budget.
continue
}
}
// Debounce waiting/resume flapping
if !st.WaitingSince.IsZero() && now.Sub(st.WaitingSince) < time.Duration(e.opts.WaitingResumeDebounceSec)*time.Second {