mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-10 06:58:59 +02:00
fix(review): skip nested codex spawns when already running under a Codex host (#2519)
/review executed inside a Codex host spawned the codex specialist passes anyway — the same model reviewing itself, at multiplied cost (observed: 15M tokens for a single /review). Detection per maintainer decision 7: a presence probe of the Codex session env. A live Codex session exports CODEX_THREAD_ID and CODEX_SANDBOX into every shell it spawns — verified during implementation against a live `codex exec 'env | grep -i codex'` capture on codex 0.147.0 (CODEX_THREAD_ID, CODEX_SANDBOX=seatbelt, CODEX_SANDBOX_NETWORK_DISABLED=1, CODEX_CI=1). The shared codexPreflight in scripts/resolvers/constants.ts (consumed by all three review.ts army blocks: adversarial, codex plan review, codex doc review) now yields CODEX_MODE=under_codex and instructs exactly one printed notice — '[running under Codex — nested codex passes skipped; set GSTACK_FORCE_CODEX_REVIEW=1 to force]'. The override env var forces the nested passes for users who really want them. codex/SKILL.md.tmpl Step 0.5 gains the same probe: /codex under a Codex host stops with a one-line notice, since its whole value is a SECOND model's opinion. test/codex-under-codex-detection.test.ts runs the rendered preflight bash under all four env combinations (thread-id only, sandbox only, forced, clean) and asserts the probe + notice render in the three preflight consumers and the codex skill. Fixes #2519 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
73c96f9c12
commit
ae47c29b82
+12
-1
@@ -895,7 +895,11 @@ known-bad list. Sourcing `gstack-codex-probe` loads the shared helpers that both
|
||||
_TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || echo off)
|
||||
source ~/.claude/skills/gstack/bin/gstack-codex-probe
|
||||
|
||||
if ! _gstack_codex_auth_probe >/dev/null; then
|
||||
# Running-under-Codex presence probe (#2519): a live Codex session exports
|
||||
# CODEX_THREAD_ID / CODEX_SANDBOX into every shell it spawns.
|
||||
if [ "${GSTACK_FORCE_CODEX_REVIEW:-0}" != "1" ] && { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ]; }; then
|
||||
echo "UNDER_CODEX"
|
||||
elif ! _gstack_codex_auth_probe >/dev/null; then
|
||||
_gstack_codex_log_event "codex_auth_failed"
|
||||
echo "AUTH_FAILED"
|
||||
else
|
||||
@@ -904,6 +908,13 @@ fi
|
||||
_gstack_codex_version_check # warns if known-bad, non-blocking
|
||||
```
|
||||
|
||||
If the output contains `UNDER_CODEX`, stop with exactly one line:
|
||||
"[running under Codex — /codex would nest the same model at multiplied token
|
||||
cost; skipped. Set `GSTACK_FORCE_CODEX_REVIEW=1` to force.]" The whole value
|
||||
of this skill is a SECOND model's opinion; inside a Codex host it is the same
|
||||
model reviewing itself, and nested spawns have burned 15M tokens in one
|
||||
/review (#2519).
|
||||
|
||||
If the output contains `AUTH_FAILED`, stop and tell the user:
|
||||
"No Codex authentication found. Run `codex login` or set `$CODEX_API_KEY` / `$OPENAI_API_KEY`, then re-run this skill."
|
||||
|
||||
|
||||
+12
-1
@@ -68,7 +68,11 @@ known-bad list. Sourcing `gstack-codex-probe` loads the shared helpers that both
|
||||
_TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || echo off)
|
||||
source ~/.claude/skills/gstack/bin/gstack-codex-probe
|
||||
|
||||
if ! _gstack_codex_auth_probe >/dev/null; then
|
||||
# Running-under-Codex presence probe (#2519): a live Codex session exports
|
||||
# CODEX_THREAD_ID / CODEX_SANDBOX into every shell it spawns.
|
||||
if [ "${GSTACK_FORCE_CODEX_REVIEW:-0}" != "1" ] && { [ -n "${CODEX_THREAD_ID:-}" ] || [ -n "${CODEX_SANDBOX:-}" ]; }; then
|
||||
echo "UNDER_CODEX"
|
||||
elif ! _gstack_codex_auth_probe >/dev/null; then
|
||||
_gstack_codex_log_event "codex_auth_failed"
|
||||
echo "AUTH_FAILED"
|
||||
else
|
||||
@@ -77,6 +81,13 @@ fi
|
||||
_gstack_codex_version_check # warns if known-bad, non-blocking
|
||||
```
|
||||
|
||||
If the output contains `UNDER_CODEX`, stop with exactly one line:
|
||||
"[running under Codex — /codex would nest the same model at multiplied token
|
||||
cost; skipped. Set `GSTACK_FORCE_CODEX_REVIEW=1` to force.]" The whole value
|
||||
of this skill is a SECOND model's opinion; inside a Codex host it is the same
|
||||
model reviewing itself, and nested spawns have burned 15M tokens in one
|
||||
/review (#2519).
|
||||
|
||||
If the output contains `AUTH_FAILED`, stop and tell the user:
|
||||
"No Codex authentication found. Run `codex login` or set `$CODEX_API_KEY` / `$OPENAI_API_KEY`, then re-run this skill."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user