Skip to content

fix(grok): keep routine watcher cycles in one tracked task - #2914

Open
withally wants to merge 1 commit into
kunchenguid:mainfrom
withally:fm/fm-grok-completion-loop-u1
Open

fix(grok): keep routine watcher cycles in one tracked task#2914
withally wants to merge 1 commit into
kunchenguid:mainfrom
withally:fm/fm-grok-completion-loop-u1

Conversation

@withally

Copy link
Copy Markdown

Problem

Grok Build injects a synthetic task_completed prompt when a tracked background watcher process closes. That prompt is billed before hook-side handling can decide whether the close was routine.

In one measured primary-session interval, 39 of 41 billed turns were synthetic watcher completions. They consumed 93.1% of the interval tokens. Five consecutive routine watcher tasks closed in 44.0 to 53.1 seconds each and generated five prompts before the next human query.

Change

Add bin/fm-watch-grok-longrun.sh as the one Grok tracked background task. It runs the verified arm wrapper in the foreground and keeps the tracked task open across the exact routine declared-pause and captain-hold recheck results. It exits only with a non-routine actionable watcher result or failure, preserving Grok native immediate wake delivery for real work.

The existing watcher remains the singleton and liveness-beacon owner. Wedge escalations, signals, checks, heartbeats, malformed output, and arm failures all remain actionable. The PreToolUse policy now blesses only the standalone long-runner shape and still denies shell &, pipelines, redirections, wrappers, and bundled commands.

A recovery marker with no durable queue row or open decision is consumed without generating a no-work close.

Verification

  • Scripted fixture reproduces five routine cycle closes inside one tracked task, exposes none as completion output, then surfaces one actionable signal exactly once.
  • Watcher arm, recovery-loop, supervision-renderer, and five-entry-form command-policy regressions pass.
  • ShellCheck 0.11.0 extended analysis passes for every changed shell surface.
  • Documentation audience and test-coverage checks pass.
  • Live Grok 1.0.5 proof: quiet recovery produced no primary turn, no long-runner completion, and no internal arm completion; one actionable signal then produced exactly one native task completion and a handled durable wake.

@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code defect remaining after review.

The new wrapper preserves actionable and failure output while retaining the two explicitly targeted routine watcher results inside one tracked Grok task, and the recovery change suppresses completion only when no durable queue row or open decision remains.

Reviews (1): Last reviewed commit: "fix(grok): keep routine watcher cycles i..." | Re-trigger Greptile

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