Skip to content

feat(nudges): proactive progress nudges during long-running turns (ENG-16200) - #68

Merged
convyusboy merged 5 commits into
boonfrom
ridho/eng-16200-progress-nudges
Jul 23, 2026
Merged

convyusboy merged 5 commits into
boonfrom
ridho/eng-16200-progress-nudges

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

While an agent turn runs long (multi-step sequence, big batch, long analysis), the agent now proactively posts short "still working on X…" messages to the user's active channel (Slack / Teams / Boon UI), so a long task never goes silent. On a long run that fails or stalls it posts one failure + next-step message instead of vanishing. Fast turns below the threshold get no nudge; completion is the normal final reply.

Implements ENG-16200. MVP scope — up-front acknowledgment and rich %/milestone progress are deferred to a follow-up.

Design

A new self-rearming poll scheduler src/infra/progress-nudge-runner.ts, modeled on heartbeat-runner.ts. It reuses existing infrastructure rather than rebuilding delivery:

  • Outbound — sendDurableMessageBatch + resolveHeartbeatDeliveryTargetWithSessionRoute({ target: "last" }) → the user's active channel. No new per-channel send path.
  • "Working on X" text — the agent-event bus (onAgentEvent, item/tool progressText).
  • Active-turn + start time + terminal signal — the reply-run registry (additive changes below).

It is deliberately not wired into the run lifecycle's control flow — it observes the registry, so it can't leak a timer onto the abort/restart paths.

Changes

  • src/infra/progress-nudge-runner.ts (new) — the scheduler.
  • src/auto-reply/reply/reply-run-registry.ts — additive: startedAt on ReplyOperation, resolveActiveReplyRunStartedAt, and an onReplyRunTerminal listener fired once per run from clearReplyRunState (a poller can't observe failed reliably because fail() clears the session key before the next tick).
  • src/config/{types.agent-defaults,zod-schema.agent-runtime,zod-schema.agent-defaults}.ts — the agents.defaults.progressNudge block (default enabled: false — upgrade-safe; the fleet enables it via config, see the gandalf-manager PR). Extracted a shared ActiveHoursSchema reused by heartbeat + nudge.
  • src/gateway/server-runtime-services.ts — starts the runner beside the heartbeat runner, composed into that handle so existing stop/reload plumbing drives both.

Correctness notes

  • Fast-task suppression falls out of the threshold (nothing fires before it).
  • Error nudge fires exactly once and only for a run that had already gone long (≥1 nudge sent) — a fast failure never went silent, so it needs none. aborted_by_user and completed never error-nudge.
  • Final-reply-race guard skips only terminal phases (completed/failed/aborted); legitimate long pre-run phases (memory_flushing, preflight_compacting) still nudge.

Tests

src/infra/progress-nudge-runner.{scheduler,error-nudge,concurrent}.test.ts, reply-run-registry.progress-nudge-hooks.test.ts, and config-schema cases. All green; pnpm tsgo:core + oxlint clean.

Rollout ordering ⚠️

This ships the runtime + config schema only (default off). The fleet enables it via config in a separate gandalf-manager PR, which must land only after this is released and rolled — an older gateway would reject the unknown config key on validation.

🤖 Generated with Claude Code


Summary by cubic

Adds proactive progress nudges for long-running agent turns so users see “still working on X…” updates; if a long run fails, sends a single failure + next‑step nudge. Off by default and reuses existing delivery; implements ENG-16200.

  • New Features

    • New scheduler startProgressNudgeRunner posts “still working” nudges after a threshold, spaced by an interval and capped by maxNudges; uses sendDurableMessageBatch + resolveHeartbeatDeliveryTargetWithSessionRoute({ target: "last" }).
    • Pulls “working on X” text from agent events; skips only terminal phases to avoid final‑reply races while still nudging during memory_flushing/preflight_compacting.
    • Failure nudges are gated by elapsed time (startedAt, via the injected clock), so runs that cross the threshold and fail between ticks still get one; delivery uses the snapshotted routeThreadId, and a fire‑once guard persists so duplicate terminal events can’t double‑nudge. Setting target: "none" suppresses both in‑turn and terminal nudges.
    • Reply‑run registry adds startedAt, resolveActiveReplyRunStartedAt, and onReplyRunTerminal; terminal events carry routeThreadId + startedAt. The runner is started beside the heartbeat runner and composed into its handle so existing stop/updateConfig drive both; test resets now clear terminal listeners.
  • Migration

    • To enable: set agents.defaults.progressNudge.enabled: true (optionally thresholdSeconds, intervalSeconds, maxNudges, target, activeHours).
    • Roll out config only after this release is deployed; older gateways reject the new progressNudge key.

Written for commit 3878416. Summary will update on new commits.

Review in cubic

convyusboy and others added 2 commits July 23, 2026 11:45
…G-16200)

While an agent turn exceeds a config-driven duration threshold, proactively
post short "still working on X…" messages to the user's active channel
(Slack/Teams/Boon UI) so a long batch/analysis never goes silent, capped by
interval + a max count. On a failed/stalled run that had gone long, post one
failure + next-step message instead of vanishing. Fast turns below the
threshold get no nudge; completion is the normal final reply.

Reuses the existing outbound layer (sendDurableMessageBatch + target:"last"),
the agent-event bus (progressText = the "working on X" content), and the
reply-run registry — no new per-channel send path. The scheduler mirrors
startHeartbeatRunner: a self-rearming, unref'd poll loop with per-sessionKey
bookkeeping and injectable deps for tests.

- src/infra/progress-nudge-runner.ts: the runner (new).
- reply-run-registry.ts: additive startedAt + resolveActiveReplyRunStartedAt +
  onReplyRunTerminal (single terminal signal so failure detection can't miss a
  fail() that clears the session key before the next poll).
- config: agents.defaults.progressNudge block (default enabled:false —
  upgrade-safe), type + zod schema.
- server-runtime-services.ts: start beside the heartbeat runner, composed into
  its handle so existing stop/updateConfig plumbing drives both.

Tests: scheduler (threshold/interval/maxNudges/generic/stop/disabled/final-reply
race/no-target), error-nudge (once/abort/completed/fast-fail), concurrent
(per-session routing), config schema, registry hooks. All green; tsgo:core +
oxlint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…s DRY (ENG-16200)

Code-review fixes:
- progress-nudge-runner: the final-reply-race guard skipped ALL non-"running"
  phases, which wrongly suppressed nudges during memory_flushing /
  preflight_compacting — legitimate long waits that are exactly the silent gaps
  this feature targets. Now skips only TERMINAL phases (completed/failed/
  aborted). Added a test that a nudge still fires during memory_flushing.
- reply-run-registry: testing.resetReplyRunRegistry() now clears the terminal
  listener Set (mirrors resetAgentEventsForTest) so a runner a test forgot to
  stop() can't leak a listener across tests. Added a regression test.
- zod-schema.agent-runtime: extracted the duplicated activeHours HH:MM validator
  into a shared ActiveHoursSchema used by both HeartbeatSchema and
  ProgressNudgeSchema (removes ~35 lines of copy-paste; error paths unchanged).

tsgo:core + oxlint clean; affected suites green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

cubic analysis

3 issues found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/config/types.agent-defaults.ts">

<violation number="1" location="src/config/types.agent-defaults.ts:468">
P3: Extract the duplicated activeHours inline type into a shared ActiveHoursSchema type alias and reuse it for both heartbeat.activeHours and progressNudge.activeHours. This matches the PR description's stated intent and avoids drift if the shape changes later.</violation>
</file>

<file name="src/infra/progress-nudge-runner.ts">

<violation number="1" location="src/infra/progress-nudge-runner.ts:223">
P2: Long-running turns do not receive the required up-front acknowledgment: this runner explicitly returns until the threshold and has no start-time message path. According to linked Linear issue ENG-16200, the agent should acknowledge the task before waiting for the first progress threshold; wiring an acknowledgment into the run-start hook would satisfy that requirement without waiting 45 seconds.</violation>

<violation number="2" location="src/infra/progress-nudge-runner.ts:253">
P2: A progress nudge can race past the final reply: the terminal-phase check happens before an asynchronous target/send operation, and the send is not cancelled or revalidated afterward. If the run completes during that await, the nudge may arrive after the final response. Capturing a per-run generation and checking/cancelling it through delivery would keep terminal output ordered.</violation>
</file>

Linked issue analysis

Linked issue: ENG-16200: Agent progress nudges during long-running processes — keep the user posted, don't go silent

Status Acceptance criteria Notes
✅ Long-running tasks are detected via a config-driven threshold (duration/step count) The PR adds a progressNudge config block (thresholdSeconds) and the runner gates nudges on the configured threshold. Tests exercise threshold gating.
✅ Agent emits progress nudges at capped intervals/milestones during execution (interval config-driven, maxNudges cap) The runner enforces interval and maxNudges and emits 'still working' messages; tests verify interval gating and maxNudges behavior.
⚠️ Agent sends a clear completion nudge with the result on success The PR documents that completion is delivered as the normal final reply (no separate completion message) rather than adding a distinct completion nudge. The runner focuses on interim 'still working' nudges and error nudges; there is no explicit new completion-message emission or tests asserting a separate completion nudge.
✅ On mid-run error / stall / poisoned session, the agent proactively nudges the failure + next step (never goes silent) The runner listens for terminal events and will send a single failure/next-step nudge for runs that had gone long. Tests validate error-nudge semantics and once-only behavior.
✅ Fast tasks below threshold do NOT get a 'still working' nudge The runner suppresses nudges before the threshold and tests cover fast-failure/no-nudge cases.
⚠️ Behavior is identical across Teams, Slack chat, and the Boon UI via existing messaging plumbing The code reuses the existing heartbeat/delivery plumbing (resolveHeartbeatDeliveryTargetWithSessionRoute and sendDurableMessageBatch), which makes the feature channel-agnostic. Tests exercise delivery target resolution and a 'none' channel case, but do not explicitly assert identical UX on each named channel.
✅ Reuse-not-rebuild: no new per-channel delivery path; hooks into existing task execution + message rendering The runner hooks into the reply-run registry and agent-event bus and reuses the existing delivery/rendering plumbing rather than adding per-channel send paths.

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread src/infra/progress-nudge-runner.ts Resolved
Comment thread src/infra/progress-nudge-runner.ts Resolved
Comment thread src/infra/progress-nudge-runner.ts Resolved
}
entry.lastNudgeSentAtMs = nowMs;
entry.nudgeCount += 1;
await deliverNudge(sessionKey, renderProgressText(entry.progressText));

@cubic-dev-ai cubic-dev-ai Bot Jul 23, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: A progress nudge can race past the final reply: the terminal-phase check happens before an asynchronous target/send operation, and the send is not cancelled or revalidated afterward. If the run completes during that await, the nudge may arrive after the final response. Capturing a per-run generation and checking/cancelling it through delivery would keep terminal output ordered.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/infra/progress-nudge-runner.ts, line 253:

<comment>A progress nudge can race past the final reply: the terminal-phase check happens before an asynchronous target/send operation, and the send is not cancelled or revalidated afterward. If the run completes during that await, the nudge may arrive after the final response. Capturing a per-run generation and checking/cancelling it through delivery would keep terminal output ordered.</comment>

<file context>
@@ -0,0 +1,384 @@
+    }
+    entry.lastNudgeSentAtMs = nowMs;
+    entry.nudgeCount += 1;
+    await deliverNudge(sessionKey, renderProgressText(entry.progressText));
+  };
+
</file context>
Fix with cubic

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Considered and intentionally not adding a generation counter here. The in-turn nudge already has a pre-send terminal-phase guard (getRunPhase skips completed/failed/aborted), which closes the common race; a nudge that still slips through arrives a beat after the reply, which is acceptable for a 'still working' message. A full generation/cancel-through-delivery mechanism would diverge from the sibling heartbeat-runner (which has the same bounded-await shape and no such counter). Happy to add it if you feel strongly — flagging as a deliberate parity choice for a maintainer call.

}
const elapsed = nowMs - startedAt;
// Fast-task suppression: nothing fires before the threshold.
if (elapsed < state.resolved.thresholdMs) {

@cubic-dev-ai cubic-dev-ai Bot Jul 23, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Long-running turns do not receive the required up-front acknowledgment: this runner explicitly returns until the threshold and has no start-time message path. According to linked Linear issue ENG-16200, the agent should acknowledge the task before waiting for the first progress threshold; wiring an acknowledgment into the run-start hook would satisfy that requirement without waiting 45 seconds.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/infra/progress-nudge-runner.ts, line 223:

<comment>Long-running turns do not receive the required up-front acknowledgment: this runner explicitly returns until the threshold and has no start-time message path. According to linked Linear issue ENG-16200, the agent should acknowledge the task before waiting for the first progress threshold; wiring an acknowledgment into the run-start hook would satisfy that requirement without waiting 45 seconds.</comment>

<file context>
@@ -0,0 +1,384 @@
+    }
+    const elapsed = nowMs - startedAt;
+    // Fast-task suppression: nothing fires before the threshold.
+    if (elapsed < state.resolved.thresholdMs) {
+      return;
+    }
</file context>
Fix with cubic

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Correct per the ticket, but the up-front acknowledgment is explicitly out of scope for this MVP (the PR description lists it as deferred). It needs a run-START hook (this runner is threshold-triggered by design), which is a separate wiring point. Tracked as a fast follow-up on the same runner. Leaving open for visibility.

Comment thread src/config/types.agent-defaults.ts Resolved
…ix broken mocks (ENG-16200)

Addresses #68 review + CI:

- CI (check-test-types): adding required `startedAt` to ReplyOperation broke two
  pre-existing mock fixtures (agent-runner-execution/memory tests) — add startedAt:0.
- CI (startup-health-runtime): the returned heartbeatRunner is now a composite of
  the heartbeat + progress-nudge runners; the test asserted exact-identity. Mock
  the nudge runner and assert the composed handle delegates stop()/updateConfig()
  to both.
- P1 (failure between ticks): "went long" now derives from elapsed run time
  (terminal event's startedAt) instead of nudgeCount>0, so a run that crosses the
  threshold then fails BETWEEN poll ticks still gets its failure nudge. Added a
  regression test.
- P2 (thread route): ReplyRunTerminalEvent now carries routeThreadId (+ startedAt),
  snapshotted at clear time; the terminal nudge delivers to that explicit route
  instead of a live registry lookup that returns undefined post-clear.
- P2 (target:"none"): the terminal failure nudge is now gated on
  enabled && target !== "none", so a disabled delivery target suppresses it too.
  Added a test.

tsgo:core + tsgo:core:test + oxlint clean; all affected suites green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 7 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/infra/progress-nudge-runner.ts Resolved
convyusboy and others added 2 commits July 23, 2026 17:00
…(ENG-16200)

handleTerminal computed elapsed with Date.now() directly, ignoring the runner's
injected now() clock that the scheduler path already uses. A fake/custom-clock
run could gate the error nudge differently from the rest of the runner. Use
now() so terminal gating is clock-consistent and deterministic under test.

#68 review (cubic P3). tsgo:core + oxlint clean; runner suites green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t double-nudge (ENG-16200)

CI (checks-node-bundle-infra-small-3) caught a regression from the elapsed-based
wentLong change: handleTerminal deleted the nudge bookkeeping entry right after
firing the error nudge, but since wentLong is now elapsed-based (not entry-
dependent), a second terminal event for the same session re-fired — the
errorNudgeSent guard died with the deleted entry. Now the error-nudge path stamps
and KEEPS the entry (creating one if the failure happened between ticks); the
tick-prune reclaims it once the session is inactive. The common no-nudge terminal
path still deletes immediately. Added a repeat-terminal regression test for the
between-ticks case. (The `dispatch` job failure was downstream of this shard.)

tsgo:core + oxlint clean; runner suites green (17/17).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the full diff (ENG-16200). Approving.

What it does: self-rearming poll scheduler (progress-nudge-runner.ts, modeled on heartbeat-runner) that posts "still working on X…" nudges once a turn crosses a threshold, plus one failure+next-step nudge if a long run fails. Default off, upgrade-safe.

Strengths

  • Cleanly observes the reply-run registry rather than wiring into the run lifecycle — can't leak a timer onto abort/restart paths. Good isolation.
  • Reuses existing delivery (sendDurableMessageBatch + heartbeat target resolution) and the agent-event bus for progress text — no new per-channel send path, minimal surface.
  • Registry changes are purely additive (startedAt, resolveActiveReplyRunStartedAt, onReplyRunTerminal).
  • Nice DRY: extracted shared ActiveHoursSchema so the 24:00 edge-case validation lives in one place for both heartbeat + nudge.
  • Terminal event carries startedAt + routeThreadId snapshot, so the failure gate is elapsed-based (catches a run that crosses threshold then fails between poll ticks) and stays attributable after the op leaves the registry.
  • Fire-once error guard that deliberately outlives the handler; tick-prune reclaims it.

Tests — thorough on exactly the tricky edges: threshold suppression, interval cap, maxNudges, terminal-phase final-reply race, between-ticks failure, user-abort exclusion, target=none suppression (both in-turn + terminal), concurrent per-thread routing, listener cleanup, and full schema accept/reject cases.

CI: 106/106 checks green. No secrets in diff or history. No breaking migration (default enabled:false); rollout ordering (runtime before the gandalf-manager config PR) is correctly called out. Ship it.

@convyusboy
convyusboy merged commit e7be2cf into boon Jul 23, 2026
145 checks passed
@convyusboy
convyusboy deleted the ridho/eng-16200-progress-nudges branch July 23, 2026 13:41
convyusboy added a commit that referenced this pull request Jul 23, 2026
Bump gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.7 in
lockstep (package.json + npm-shrinkwrap.json roots) and add the CHANGELOG entry.
Ships the boon.7 train: #70 (ENG-16418 concise + A/B/C overlay for Claude),
#68 (ENG-16200 progress nudges runtime, gated off by default), #69 (security
dep bumps), #64 (ENG-16330 non-terminal recovered-tool-error badge).

Base = 2026.6.11-boon.6. Only slack + msteams carry the -boon.N suffix; other
extensions stay at plain 2026.6.11 (fork release does not run a blanket
plugins:sync). Formatting proof: oxfmt --check clean on CHANGELOG.md; the six
JSON files are oxfmt-excluded lockfile-class and byte-shape-identical to the
boon.6 release commit.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant