feat(session-kind): explicit GSTACK_SESSION_KIND override; skill-start spawned gates keyed on kind (#2733)

Claude Code subagents inherit the parent env byte-for-byte, so ambient
markers classify them as the parent's kind and the spawned classification
was unreachable outside OpenClaw. GSTACK_SESSION_KIND=spawned (step 0,
spawned-only by design) lets a dispatching skill mark its subagent per
command. skill-start now keys SPAWNED_SESSION and the spawned-session
instruction block on the resolved kind (was raw OPENCLAW_SESSION),
suppresses CONDUCTOR_SESSION for spawned sessions, gates all 11
interactive-onboarding blocks plus their ack-at-emit marker writes on
kind != spawned, and adds a destructive-gate carve-out to the spawned
block (conservative-continue, never prose-STOP).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-30 23:33:40 +00:00
co-authored by Claude Fable 5
parent 07b59e396c
commit 5486cd6620
5 changed files with 136 additions and 6 deletions
+20
View File
@@ -17,11 +17,31 @@
# a positive headless signal, since a stray prose message in an unmarked one-shot
# `-p` run just ends the turn (harmless), whereas wrongly BLOCKING a real human is not.
#
# GSTACK_SESSION_KIND=spawned is the explicit per-command override (step 0 below),
# outranking every ambient marker. Deliberately narrow — only "spawned" is honored:
# Claude Code subagents inherit the parent env byte-for-byte (#2733), so a
# dispatching skill marks its subagent by prefixing the gstack-skill-start
# invocation. "headless" already has GSTACK_HEADLESS; other values are reserved
# and ignored (fall through to detection).
#
# Why env vars and not TTY/entrypoint: an interactive Conductor session reports
# CLAUDE_CODE_ENTRYPOINT=sdk-ts with no TTY — identical to a headless SDK eval. The
# signals that actually discriminate are the host/orchestrator/CI env markers below.
set -euo pipefail
# 0. Explicit spawned marker — set per-command by a dispatching skill (e.g.
# /ship Step 18 prefixes the document-release subagent's gstack-skill-start
# with GSTACK_SESSION_KIND=spawned; #2733: Claude Code subagents inherit
# the parent env byte-for-byte, so ambient markers misclassify them as the
# parent's kind). Only "spawned" is honored: headless already has
# GSTACK_HEADLESS, and letting an env var force "interactive" over CI
# markers would be a misclassification footgun. Other values are reserved
# and ignored (fall through) — same contract as empty GSTACK_HEADLESS.
if [ "${GSTACK_SESSION_KIND:-}" = "spawned" ]; then
echo "spawned"
exit 0
fi
# 1. Orchestrator-spawned session (OpenClaw). Authoritative block lives in the skill;
# we only surface the classification.
if [ -n "${OPENCLAW_SESSION:-}" ]; then