AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Plan: Fix Grok Auth Honesty
Date: 2026-08-14
Status: Implemented
PR: fix(grok): treat expired sessions as degraded, not ok
Problem (measured 2026-08-14 Peter Steinberger run on the user's Mac)
- grok binary on PATH. Doctor cached grok status ok / will use grok because
~/.grok/auth.jsonexisted with token markers. stored_auth_status()substring-scans forrefresh_token/access_token/auth_mode. It never parsesexpires_at.- The file had
expires_at 2026-08-14T01:26:53Z, hours dead. - A prior run at 07:47:26 UTC had
run_outcomeok (2 items). Session was real. - At 08:43 grok loaded auth,
is_expiredtrue, OIDC refresh →invalid_grant"Refresh token has been revoked". grok deleted auth.json. - Engine exit 1 "Not signed in", fell back to bird (30 items via Safari cookies), lane flagged PARTIAL.
- Host told the user "Grok CLI is not signed in" as if it never was.
Three states to distinguish
- No grok CLI — silent fallback. Fine. Do not waste the user's time. Do not nag install on every research run.
- CLI installed, never logged in — silent fallback. Fine.
- CLI installed, WAS logged in, session dead — currently reports ok then partial. This is the bug.
What was built
stored_auth_statusparsesexpires_atlocally (no network, no subprocess). AddedAUTH_EXPIREDdistinct fromAUTH_OK/AUTH_MISSING/AUTH_ERROR. Never echoes token values. Findsexpires_atanywhere in the vendor-keyed JSON object via recursive search.Doctor /
_probe_grokdoes NOT mapAUTH_EXPIREDtohealth.OKor "will use: grok". ReportsDEGRADED/warn + expiry timestamp + "refresh happens at run; if refresh was revoked,grok login --device-auth".Research-time
is_availableSTILL attempts grok when arefresh_tokenmarker is present even ifaccessexpires_atis past. Expiry of the access token is not proof refresh is dead. Does not skip a refresh that might work.Auth revocation detection: If grok exits "Not signed in" / RefreshTokenRejected / auth.json vanished mid-run: does not retry grok in that run. Falls back once. Typed outcome
auth-failed(viais_auth_revoked_error()andclassify_run_failure()), not a generic PARTIAL that reads as "the product half-worked."Host-facing copy for case 3: SKILL.md updated with guidance: "X used after the Grok session expired" + login hint. Not "Grok CLI is not signed in" when
run_outcomeshows it worked earlier.Doctor --probe still does not call xAI or grok. Whole-doctor-path test patches
subprocess.runto raise and still passes.active_backendstays a prediction; whenrun_outcome.atis stale or not ok, doctor says "will use grok, unverified sinceTests: Fixture stores (missing file, future
expires_at, pastexpires_at, unparseable JSON). No network.SKILL.md: Host reads
sources.x.run_outcomeand grok expiry warn; does not treatactive_backendas verified; does not spend a turn installing grok unless the user asked for first-party X.Changelog fragment:
changelog.d/+grok-auth-expired.fixed.md. Tests pass withuv run pytest.
Scope boundaries (NOT in this PR)
- X query construction, fanout,
search_name, retrieve-judge-retry, and handle promotion are unchanged. That is a separate PR.
Success criteria (all met)
- Past
expires_atfixture → not grok ok. - Future
expires_at→ still ok (not live-verified). - No grok binary → no extra user-facing failure.
- Simulated "Not signed in" after prior ok
run_outcome→ typedauth-failed/ fallback copy, not "never signed in." - No-subprocess doctor test still passes.
Files changed
skills/last30days/scripts/lib/grok_x.py—AUTH_EXPIRED,stored_auth_status()returns 3-tuple,is_auth_revoked_error(),classify_run_failure(),_invoke()setsauth_revoked,_run_query()returns 3-tuple,search_x()propagatesauth_revokedskills/last30days/scripts/lib/backends.py—_probe_grok()handlesAUTH_EXPIREDasDEGRADEDskills/last30days/scripts/lib/pipeline.py—_fetch_x_backend()propagatesauth_revoked,_classify_source_failure()recognizes grok markersskills/last30days/SKILL.md— Grok session expiry handling guidancetests/test_grok_x.py— expires_at and auth revocation teststests/test_backend_descriptors.py— grok expiry state testschangelog.d/+grok-auth-expired.fixed.md— release notes fragment