mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-24 09:01:28 +01:00
/review on Codex with OpenAI models no longer blocks a review that ran its adversarial pass (GST-3375) (#4622)
/review on Codex no longer blocks or logs a miss for sessions that really ran the adversarial review, when the model is an OpenAI one. Why: Codex encrypts the message it sends a new subagent for OpenAI models, so the check never saw the review brief's text; it now accepts a started subagent named `adversarial` whose message is encrypted. Nothing to do: Claude Code's check is unchanged, and a plaintext, missing, failed or differently named subagent still counts as missing. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
bd77c8ccaa
commit
de9a7b4adc
13 files changed
+196
-44
No files matched your search
+21
-8
@@ -27,7 +27,11 @@
|
||||
* gpt-6.1-sol); a call with no namespace may carry either. One whose output
|
||||
* names no id for its namespace (it failed, or it has no output), or a
|
||||
* same-named tool in any other namespace, stays a plain spawn_agent call,
|
||||
* so it is not a dispatch.
|
||||
* so it is not a dispatch. The dispatch also carries the started agent's
|
||||
* task name (the last part of its "/root/<name>" result, else the call's
|
||||
* task_name), and sealed when its message is ciphertext: Codex encrypts the
|
||||
* multi_agents_v2 message for OpenAI models (openai/codex#26210), so the
|
||||
* brief's text is in neither rollout.
|
||||
* - any other call: a tool_use under its own name. Call outputs are
|
||||
* tool_results; a shell output that exited non-zero is an error.
|
||||
* Records of other types (event_msg, turn_context, reasoning and the rest)
|
||||
@@ -46,6 +50,7 @@ const READ_PROGRAM = /(?:^|[\s;|&(`'"])(?:cat|sed|head|tail|nl|less|more|bat|awk
|
||||
const READ_FAILURE = /No such file|cannot open|can't read|cannot access|Permission denied|Is a directory|Cannot find path/i;
|
||||
const SHELL_TOOLS = new Set(['exec_command', 'shell', 'shell_command', 'local_shell']);
|
||||
const EXIT_CODE = /(?:^|\n)Process exited with code (\d+)/;
|
||||
const CIPHERTEXT = /^gAAAAA[A-Za-z0-9_-]{20,}={0,2}$/;
|
||||
|
||||
/** Whether text is a Codex rollout: its first JSON object line is a session_meta record. */
|
||||
export function isCodexRollout(text: string): boolean {
|
||||
@@ -156,17 +161,18 @@ const exitedNonZero = (output: string | undefined) => {
|
||||
return !!code && code[1] !== '0';
|
||||
};
|
||||
|
||||
const startedAgent = (output: string | undefined, namespace: unknown) => {
|
||||
if (output === undefined) return false;
|
||||
/** A spawn_agent output that names the agent it started, for the call's namespace, or null. */
|
||||
const startedAgent = (output: string | undefined, namespace: unknown): Record<string, any> | null => {
|
||||
if (output === undefined) return null;
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(output);
|
||||
if (!isObject(parsed)) return false;
|
||||
if (!isObject(parsed)) return null;
|
||||
const ids = namespace === 'multi_agent_v1' ? [parsed.agent_id]
|
||||
: namespace === 'collaboration' ? [parsed.task_name]
|
||||
: namespace === undefined ? [parsed.agent_id, parsed.task_name] : [];
|
||||
return ids.some(id => typeof id === 'string' && id !== '');
|
||||
return ids.some(id => typeof id === 'string' && id !== '') ? parsed : null;
|
||||
} catch {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -228,6 +234,7 @@ export function parseCodexRollout(text: string): Transcript {
|
||||
const id = String(p.call_id ?? '');
|
||||
const input = args(p.type === 'custom_tool_call' ? { input: p.input } : p.arguments, line);
|
||||
const command = SHELL_TOOLS.has(p.name) ? shellLine(input) : null;
|
||||
const started = p.name === 'spawn_agent' ? startedAgent(outputs.get(id), p.namespace ?? undefined) : null;
|
||||
if (command !== null) {
|
||||
events.push({ kind: 'tool_use', line, id, name: 'Bash', input: { command } });
|
||||
const reads = shellSkillReads(command);
|
||||
@@ -237,10 +244,16 @@ export function parseCodexRollout(text: string): Transcript {
|
||||
events.push({ kind: 'load', line, skill: read.skill, via: 'read' });
|
||||
lastLoad = read.skill;
|
||||
}
|
||||
} else if (p.name === 'spawn_agent' && startedAgent(outputs.get(id), p.namespace ?? undefined)) {
|
||||
} else if (started) {
|
||||
const prompt = [input.message, ...(Array.isArray(input.items) ? input.items.map((i: unknown) => (isObject(i) ? i.text : undefined)) : [])]
|
||||
.filter(v => typeof v === 'string').join('\n');
|
||||
events.push({ kind: 'tool_use', line, id, name: 'Agent', input: { prompt, ...(typeof input.agent_type === 'string' ? { subagent_type: input.agent_type } : {}) } });
|
||||
const taskName = [started.task_name, input.task_name].find(v => typeof v === 'string' && v !== '')?.split('/').pop();
|
||||
events.push({ kind: 'tool_use', line, id, name: 'Agent', input: {
|
||||
prompt,
|
||||
...(typeof input.agent_type === 'string' ? { subagent_type: input.agent_type } : {}),
|
||||
...(taskName ? { task_name: taskName } : {}),
|
||||
...(typeof input.message === 'string' && CIPHERTEXT.test(input.message) ? { sealed: true } : {}),
|
||||
} });
|
||||
} else {
|
||||
events.push({ kind: 'tool_use', line, id, name: p.name, input });
|
||||
}
|
||||
|
||||
+14
-4
@@ -42,6 +42,8 @@ export interface ContractItem {
|
||||
heading?: string;
|
||||
labels?: string[];
|
||||
match?: string;
|
||||
/** agent_dispatch on Codex: the task name that stands in for match when Codex encrypted the spawn message. */
|
||||
task_name?: string;
|
||||
marker?: string;
|
||||
empty_marker?: string;
|
||||
fix?: string;
|
||||
@@ -89,7 +91,8 @@ export function parseContract(frontmatter: string): { contract: Contract } | { e
|
||||
return validateContract(isObject(doc) ? doc.contract : undefined);
|
||||
}
|
||||
|
||||
const STRING_FIELDS = ['heading', 'match', 'marker', 'empty_marker', 'fix', 'summary'] as const;
|
||||
const STRING_FIELDS = ['heading', 'match', 'task_name', 'marker', 'empty_marker', 'fix', 'summary'] as const;
|
||||
const TASK_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
||||
const REGEX_FIELDS = ['match'] as const;
|
||||
|
||||
/**
|
||||
@@ -153,6 +156,8 @@ export function validateContract(raw: unknown): { contract: Contract } | { error
|
||||
out.labels = item.labels.map((l: string) => l.trim());
|
||||
}
|
||||
if (out.kind === 'agent_dispatch' && !out.match) return { error: `${id}: agent_dispatch needs match` };
|
||||
if (out.task_name !== undefined && out.kind !== 'agent_dispatch') return { error: `${id}: task_name applies only to agent_dispatch` };
|
||||
if (out.task_name !== undefined && !TASK_NAME.test(out.task_name)) return { error: `${id}: task_name must match ${TASK_NAME}` };
|
||||
if (out.kind === 'agent_dispatch' && out.marker) return { error: `${id}: agent_dispatch takes no marker until the checker can bind a marker to the dispatch it names (GST-1242)` };
|
||||
items.push(out);
|
||||
}
|
||||
@@ -370,9 +375,14 @@ function checkItem(item: ContractItem, run: TranscriptEvent[], codex: boolean):
|
||||
case 'agent_dispatch': {
|
||||
const re = new RegExp(item.match as string, 'i');
|
||||
if (codex) {
|
||||
return agents.some(a => re.test(agentText(a)))
|
||||
? { met: true, detail: `a spawn_agent call matches /${item.match}/`, fix: '' }
|
||||
: { met: false, detail: `no spawn_agent call matches /${item.match}/`, fix: item.fix ?? `start the subagent pass matching /${item.match}/ with spawn_agent, then wait_agent for its result` };
|
||||
if (agents.some(a => re.test(agentText(a)))) return { met: true, detail: `a spawn_agent call matches /${item.match}/`, fix: '' };
|
||||
if (item.task_name && agents.some(a => a.input.sealed === true && a.input.task_name === item.task_name)) {
|
||||
return { met: true, detail: `spawn_agent started ${item.task_name} with an encrypted message`, fix: '' };
|
||||
}
|
||||
const fix = item.task_name
|
||||
? `start the subagent pass with spawn_agent (task_name "${item.task_name}", its message matching /${item.match}/), then wait_agent for its result`
|
||||
: `start the subagent pass matching /${item.match}/ with spawn_agent, then wait_agent for its result`;
|
||||
return { met: false, detail: `no spawn_agent call matches /${item.match}/`, fix: item.fix ?? fix };
|
||||
}
|
||||
return agents.some(a => re.test(agentText(a)))
|
||||
? { met: true, detail: `an Agent dispatch matches /${item.match}/`, fix: '' }
|
||||
|
||||
Reference in new issue
Block a user