Skip to content

fix(grok-build): start the watcher when GROK_SESSION_ID is empty (#236 follow-up)#238

Merged
fujibee merged 1 commit into
mainfrom
fix/grok-watch-empty-sid
Jun 26, 2026
Merged

fix(grok-build): start the watcher when GROK_SESSION_ID is empty (#236 follow-up)#238
fujibee merged 1 commit into
mainfrom
fix/grok-watch-empty-sid

Conversation

@fujibee

@fujibee fujibee commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #236. A real-grok end-to-end test of the new grok-build monitor
delivery surfaced a first-launch failure: Grok's monitor tool does not reliably
export GROK_SESSION_ID into the launched command's shell, so the rule's literal
"$GROK_SESSION_ID" expands to empty and watch.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 a
    fallback agmsg-<uuid> (mirroring the bridge's CLAUDE_CODE_SESSION_ID
    fallback) instead of failing. project_path and agent_type stay 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 comment
    that claimed "Grok exports GROK_SESSION_ID for every subprocess".
  • tests/test_watch.bats: assert an empty session id starts the watcher (a
    fallback watch.agmsg-*.pid appears, no Usage error) instead of exiting.

Verification

  • Local bats tests/test_watch.bats green (incl. the new case).
  • Found by spawning a real grok-build agent (grok 0.2.67) with monitor delivery:
    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/--resume isolation (#93) is
best-effort for that watcher, the same as the existing bare-session-id fallback.

…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.
@fujibee fujibee merged commit 3a0f29d into main Jun 26, 2026
5 of 6 checks passed
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