fix(hooks): spawned-session escape in Conductor AUQ deny; override coverage in AUQ-error fallback (#2733)

Hooks inherit the harness env, so a per-command GSTACK_SESSION_KIND
prefix inside a subagent's bash can never reach them. Levers added:
a deterministic [conductor][spawned] auto-choose deny for env-level
spawned sessions (OPENCLAW_SESSION or session-wide GSTACK_SESSION_KIND),
and a spawned escape sentence appended to both hooks' prose directives
so a marked subagent that slips and calls AUQ resolves to auto-choose
instead of prose-STOP. The sentence lives in one shared constant
(hosts/claude/hooks/spawned-directive.ts) so the two paths can never
drift; destructive semantics are unified to conservative-continue.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-30 23:42:38 +00:00
co-authored by Claude Fable 5
parent 5486cd6620
commit 9c7b0a2c95
5 changed files with 158 additions and 2 deletions
@@ -32,6 +32,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { runBin } from './spawn-bin';
import { SPAWNED_ESCAPE_SENTENCE } from './spawned-directive';
interface HookStdin {
tool_name?: string;
@@ -158,12 +159,17 @@ export function directiveFor(kind: 'spawned' | 'headless' | 'interactive'): stri
);
case 'interactive':
default:
// #2733: the shell-out above runs in the HARNESS env, so a subagent
// marked spawned via a per-command env prefix still classifies as
// interactive here — the escape sentence is the only lever for that
// topology (see spawned-directive.ts).
return (
lead +
'SESSION_KIND=interactive — render the decision as a PROSE message now: a clear ELI10 of the issue, ' +
'then a Recommendation line, then ONE paragraph per choice carrying its `(recommended)` marker, its ' +
'`Completeness: X/10`, and 2-4 sentences of reasoning. Tell the user to reply with a letter, then STOP. ' +
'(Retry the call once first only if no answer could have surfaced.)'
'(Retry the call once first only if no answer could have surfaced.) ' +
SPAWNED_ESCAPE_SENTENCE
);
}
}