fix(grok-build): start the watcher when GROK_SESSION_ID is empty (#236 follow-up)#238
Merged
Conversation
…follow-up)
A real-grok e2e of the new monitor delivery showed the watcher's first launch
failing fast: Grok's `monitor` tool does not reliably export GROK_SESSION_ID into
the command's shell, so the rule's literal "$GROK_SESSION_ID" expands to empty
and `watch.sh "" ...` died on `${1:?Usage}`. Grok recovered on a retry, but a
less capable agent (or a different grok build) would leave the monitor down.
watch.sh now self-assigns a fallback id (agmsg-<uuid>, mirroring the bridge's
CLAUDE_CODE_SESSION_ID fallback) when its first arg is empty, instead of failing;
project_path and agent_type stay required. Corrects the now-false "Grok exports
GROK_SESSION_ID for every subprocess" comment in the grok-build delivery plug.
Adds a watch.sh test asserting an empty session id starts the watcher (fallback
id, no Usage error) rather than exiting.
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.
Summary
Follow-up to #236. A real-grok end-to-end test of the new grok-build
monitordelivery surfaced a first-launch failure: Grok's
monitortool does not reliablyexport
GROK_SESSION_IDinto the launched command's shell, so the rule's literal"$GROK_SESSION_ID"expands to empty andwatch.sh "" ...died on${1:?Usage}("Task failed in 0.1s"). The grok agent recovered on a retry, but a less capable
agent (or a different grok build) would leave the monitor down — so the watcher
must not depend on a session id being present in its shell.
Change
scripts/watch.sh: when the first arg (session_id) is empty, self-assign afallback
agmsg-<uuid>(mirroring the bridge'sCLAUDE_CODE_SESSION_IDfallback) instead of failing.
project_pathandagent_typestay required.Claude Code is unaffected (it always bakes a real
CLAUDE_CODE_SESSION_ID).scripts/drivers/types/grok-build/_delivery.sh: correct the now-false commentthat claimed "Grok exports GROK_SESSION_ID for every subprocess".
tests/test_watch.bats: assert an empty session id starts the watcher (afallback
watch.agmsg-*.pidappears, noUsageerror) instead of exiting.Verification
bats tests/test_watch.batsgreen (incl. the new case).before, the first watcher launch failed with the Usage error; the fallback makes
it start on the first try. Real-time delivery (send ->
<monitor-event>) works.Trade-off: a generated id means parallel
--continue/--resumeisolation (#93) isbest-effort for that watcher, the same as the existing bare-session-id fallback.