fix(grok): keep routine watcher cycles in one tracked task - #2914
Open
withally wants to merge 1 commit into
Open
fix(grok): keep routine watcher cycles in one tracked task#2914withally wants to merge 1 commit into
withally wants to merge 1 commit into
Conversation
Confidence Score: 5/5The 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Grok Build injects a synthetic
task_completedprompt 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.shas 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