grok: fix xsearch (multi-agent web_search), pin grok-build, RTFM doc sweep
Root-caused the long-standing `ask-grok.sh xsearch` "no result (stopReason=)" failure by reading Grok's bundled docs (~/.grok/docs/user-guide + README) instead of probing: - web_search runs a SEPARATE multi-agent model (grok-4.20-multi-agent), so the wrapper's blanket --no-subagents strangled it -> indefinite hang, 0 bytes. Scoped --no-subagents OFF xsearch; use --yolo (documented headless tool-run posture). - xsearch prompt mandated X/Twitter search on every call (slow multi-agent) and the budget was 240s -> still timed out. Now web-primary (X only when relevant), 300s. Validated end-to-end through the wrapper: 23s, correct answer + 3 sources. Model: pin -m grok-build (xAI flagship, 512k, the documented default) for the reasoning modes (text/verify/review*) so quality is deterministic and not at the mercy of the runtime default (this machine drifted to grok-composer-2.5-fast, a fast Cursor coding model). xsearch + image/video keep the runtime default. Validated text mode on grok-build (13s). Doc accuracy (SKILL.md): corrected the model facts (default, the separate web_search model, --effort unsupported on grok-build per supports_reasoning_effort:false); documented the xsearch subagent exception. Fixed a stale in-script comment claiming --rules/--disallowed-tools "tripped the CLI" (both are valid headless flags). memory: add feedback_interview_ai_read_docs (read bundled docs / interview the model before probing) + index; errorlog correction. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,12 +94,27 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
TIMEOUT_CMD="$(command -v gtimeout 2>/dev/null || echo timeout)"
|
||||
fi
|
||||
|
||||
# Policy flags, overridable per mode. Defaults suit the single-context subordinate
|
||||
# calls (text/verify/review): a fixed permission posture and NO subagent fan-out --
|
||||
# that keeps a one-shot second-opinion call cheap, bounded, and timeout-predictable.
|
||||
# xsearch OVERRIDES both: web_search runs the grok-4.20-multi-agent model, so
|
||||
# --no-subagents made it hang with zero output (root cause, 2026-06-16). See xsearch.
|
||||
GROK_PERM_FLAGS=(--permission-mode dontAsk)
|
||||
GROK_SUBAGENT_FLAGS=(--no-subagents)
|
||||
# Pin xAI's flagship grok-build for the reasoning modes (text/verify/review*) so the
|
||||
# second-opinion quality is deterministic and not at the mercy of the runtime default
|
||||
# (which drifts -- this machine's `grok models` reports grok-composer-2.5-fast, a fast
|
||||
# Cursor coding model). xsearch + image/video clear this to "" to use the runtime
|
||||
# default (xsearch's searcher is a separate model; media gen was verified on default).
|
||||
GROK_MODEL="${GROK_MODEL:-grok-build}"
|
||||
|
||||
run_grok() {
|
||||
local to="$1"; shift
|
||||
local mflag=(); [ -n "$GROK_MODEL" ] && mflag=(-m "$GROK_MODEL")
|
||||
# Hand grok native-Windows paths (cygpath); MSYS leaves already-Windows paths alone,
|
||||
# so conversion is deterministic and space-safe.
|
||||
"$TIMEOUT_CMD" "$to" "$GROK" --prompt-file "$(winpath "$PF")" --output-format json \
|
||||
--permission-mode dontAsk --no-subagents --no-plan --cwd "$(winpath "$RUN_CWD")" "$@" \
|
||||
"${mflag[@]}" "${GROK_PERM_FLAGS[@]}" "${GROK_SUBAGENT_FLAGS[@]}" --no-plan --cwd "$(winpath "$RUN_CWD")" "$@" \
|
||||
>"$OUT" 2>"$TMP/err.txt" || true
|
||||
}
|
||||
|
||||
@@ -161,9 +176,12 @@ case "$MODE" in
|
||||
SRC="${1:-}"
|
||||
fi
|
||||
[ -z "$SRC" ] && { echo "usage: $SELF $MODE \"<prompt>\" | $SELF $MODE --prompt-file <path>" >&2; exit 2; }
|
||||
# Prompt-level steering keeps it text-only and (for verify) adversarial.
|
||||
# (The --disallowed-tools/--rules flags tripped the CLI; --check adds a slow
|
||||
# multi-turn self-check loop — both avoided in favor of prompt steering.)
|
||||
# Prompt steering + --disable-web-search (below) keeps these text-only; no tools
|
||||
# are needed. NOTE for future hardening: --rules and --disallowed-tools ARE valid
|
||||
# headless flags (per docs/user-guide/14-headless-mode.md) and could hard-restrict
|
||||
# tools if prompt steering ever proves insufficient. --check/--self-verify also
|
||||
# exists, but it makes grok verify its OWN output -- not adversarially critique an
|
||||
# EXTERNAL claim -- so prompt steering is the correct semantic for verify mode.
|
||||
if [ "$MODE" = "verify" ]; then
|
||||
printf 'Adversarially evaluate the following claim/finding/document: try hard to find any reason it is WRONG, incomplete, or overstated. Then give a verdict plus specific justification. Answer in text only; do not use tools. Content:\n%s' "$SRC" > "$PF"
|
||||
else
|
||||
@@ -177,6 +195,7 @@ case "$MODE" in
|
||||
image)
|
||||
[ -z "${1:-}" ] && { echo "usage: $SELF image \"<prompt>\" [out.png]" >&2; exit 2; }
|
||||
out="${2:-grok-image.png}"
|
||||
GROK_MODEL="" # media gen verified on the runtime default; don't force grok-build here
|
||||
printf 'Use your image_gen tool to generate exactly this image, save it, then stop. Image: %s' "$1" > "$PF"
|
||||
run_grok 240 --disable-web-search --max-turns 12
|
||||
sid="$(jfield sessionId)"; art="$(find_artifact "$sid" images)"
|
||||
@@ -189,6 +208,7 @@ case "$MODE" in
|
||||
input="$2"; out="${3:-grok-video.mp4}"
|
||||
[ -f "$input" ] || { echo "[$SELF] input image not found: $input" >&2; exit 2; }
|
||||
cp -f "$input" "$WORK/input.jpg"
|
||||
GROK_MODEL="" # media gen verified on the runtime default; don't force grok-build here
|
||||
printf 'Use your image_to_video tool to animate input.jpg (in the current directory) into a short clip, save it, then stop. Motion: %s' "$1" > "$PF"
|
||||
run_grok 360 --disable-web-search --max-turns 20
|
||||
sid="$(jfield sessionId)"; art="$(find_artifact "$sid" videos)"
|
||||
@@ -198,8 +218,18 @@ case "$MODE" in
|
||||
;;
|
||||
xsearch)
|
||||
[ -z "${1:-}" ] && { echo "usage: $SELF xsearch \"<query>\"" >&2; exit 2; }
|
||||
printf 'Use your web_search and X/Twitter search tools to answer this, cite sources, then stop: %s' "$1" > "$PF"
|
||||
run_grok 150 --max-turns 6
|
||||
# web_search runs the grok-4.20-multi-agent model -> subagents MUST stay enabled
|
||||
# (--no-subagents made it hang with ZERO output, the long-standing xsearch bug).
|
||||
# --yolo is the documented headless tool-run posture (README/14-headless-mode.md).
|
||||
# Budget is generous: a live web_search measured ~83s end-to-end.
|
||||
GROK_SUBAGENT_FLAGS=()
|
||||
GROK_PERM_FLAGS=(--yolo)
|
||||
GROK_MODEL="" # search runs the separate grok-4.20-multi-agent model; use runtime default orchestrator
|
||||
# Lead with web_search (fast); pull in X/Twitter ONLY when the query is actually
|
||||
# about social/news/sentiment. Mandating X search on every call ran the multi-agent
|
||||
# searcher long enough to blow a 240s budget. Generous 300s budget for headroom.
|
||||
printf 'Use your web_search tool to answer this question and cite sources. Use your X/Twitter search tools ONLY if the question is specifically about social media, breaking news, or public sentiment. Then stop.\n\nQuestion: %s' "$1" > "$PF"
|
||||
run_grok 300 --max-turns 14
|
||||
txt="$(jfield text)"
|
||||
if [ -n "$txt" ]; then printf '%s\n' "$txt"; else
|
||||
echo "[$SELF] no result (stopReason=$(jfield stopReason))" >&2; _logerr "grok xsearch returned no result" --context "mode=xsearch stopReason=$(jfield stopReason)"; exit 1; fi
|
||||
|
||||
Reference in New Issue
Block a user