Support active Claude steering and turn replay mapping
- add active steering and interrupt-restart replay fixtures - update Claude adapter/orchestrator turn handling for steering - refresh replay and integration test coverage
This commit is contained in:
1 parent
1e421221d4
commit
2ad2fd9c86
15 files changed
+837
-126
No files matched your search
@@ -14,7 +14,9 @@ import type { RuntimePolicyV2Override } from "../src/orchestration-v2/RuntimePol
|
||||
import { makeCheckpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
|
||||
import { CLAUDE_MODEL_SELECTION } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
|
||||
import {
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MULTI_TURN_FIRST_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
READ_ONLY_NEVER_POLICY,
|
||||
READ_ONLY_ON_REQUEST_POLICY,
|
||||
RESTRICTED_GRANULAR_POLICY,
|
||||
@@ -46,6 +48,18 @@ const CLAUDE_RECORDINGS = {
|
||||
queryMode: "restart",
|
||||
enableTools: true,
|
||||
},
|
||||
queued_turn: {
|
||||
prompts: [MULTI_TURN_FIRST_PROMPT, MULTI_TURN_SECOND_PROMPT],
|
||||
defaultTranscriptFile: "fixtures/queued_turn/claude_transcript.ndjson",
|
||||
queryMode: "streaming",
|
||||
enableTools: true,
|
||||
},
|
||||
message_steering: {
|
||||
prompts: [MESSAGE_STEERING_INITIAL_PROMPT, MESSAGE_STEERING_STEER_PROMPT],
|
||||
defaultTranscriptFile: "fixtures/message_steering/claude_transcript.ndjson",
|
||||
queryMode: "active_steering",
|
||||
enableTools: true,
|
||||
},
|
||||
tool_call_read_only: {
|
||||
prompts: [TOOL_CALL_READ_ONLY_PROMPT],
|
||||
defaultTranscriptFile: "fixtures/tool_call_read_only/claude_transcript.ndjson",
|
||||
@@ -88,15 +102,24 @@ function readArgValue(name: string): string | undefined {
|
||||
return index >= 0 ? args[index + 1] : undefined;
|
||||
}
|
||||
|
||||
function selectedQueryMode(defaultMode: "streaming" | "restart"): "streaming" | "restart" {
|
||||
type ClaudeRecordingQueryMode = "streaming" | "restart" | "active_steering" | "interrupt_restart";
|
||||
|
||||
function selectedQueryMode(defaultMode: ClaudeRecordingQueryMode): ClaudeRecordingQueryMode {
|
||||
const raw = readArgValue("--query-mode") ?? process.env.T3_CLAUDE_REPLAY_QUERY_MODE;
|
||||
if (raw === undefined) {
|
||||
return defaultMode;
|
||||
}
|
||||
if (raw === "streaming" || raw === "restart") {
|
||||
if (
|
||||
raw === "streaming" ||
|
||||
raw === "restart" ||
|
||||
raw === "active_steering" ||
|
||||
raw === "interrupt_restart"
|
||||
) {
|
||||
return raw;
|
||||
}
|
||||
throw new Error(`Unsupported Claude replay query mode '${raw}'. Use 'streaming' or 'restart'.`);
|
||||
throw new Error(
|
||||
`Unsupported Claude replay query mode '${raw}'. Use 'streaming', 'restart', 'active_steering', or 'interrupt_restart'.`,
|
||||
);
|
||||
}
|
||||
|
||||
const scenario = readArgValue("--scenario") ?? process.env.T3_CLAUDE_REPLAY_SCENARIO ?? "simple";
|
||||
|
||||
@@ -8,6 +8,7 @@ import * as CodexClient from "effect-codex-app-server/client";
|
||||
import type * as CodexSchema from "effect-codex-app-server/schema";
|
||||
|
||||
import {
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
MULTI_TURN_FIRST_PROMPT,
|
||||
MULTI_TURN_SECOND_PROMPT,
|
||||
@@ -491,20 +492,12 @@ function scenarios(): ReadonlyArray<ReplayScenario> {
|
||||
{
|
||||
name: "immediate-steer",
|
||||
description: "Start a turn, then immediately steer the active root turn.",
|
||||
turnDefaults: {
|
||||
approvalPolicy: "never",
|
||||
sandboxPolicy: workspaceWriteSandbox(),
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
type: "steeredTurn",
|
||||
label: "steered",
|
||||
prompt: TOOL_CALL_WRITE_PROMPT,
|
||||
prompt: MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
steer: MESSAGE_STEERING_STEER_PROMPT,
|
||||
turnOverrides: {
|
||||
approvalPolicy: "on-request",
|
||||
sandboxPolicy: readOnlyFullAccessSandbox(),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import path from "node:path";
|
||||
|
||||
import {
|
||||
query,
|
||||
type CanUseTool,
|
||||
@@ -376,7 +378,7 @@ function makeReplayQueryRunner(transcript: ClaudeAgentSdkReplayTranscript): Clau
|
||||
|
||||
if (entry.type === "runtime_exit") {
|
||||
advance();
|
||||
if (entry.status === "success") {
|
||||
if (entry.status === "success" || entry.status === "cancelled") {
|
||||
return;
|
||||
}
|
||||
fail(
|
||||
@@ -572,11 +574,14 @@ export async function replayClaudeAgentSdkTranscript(input: {
|
||||
);
|
||||
}
|
||||
|
||||
function serializeReplayError(error: unknown): unknown {
|
||||
function serializeReplayError(error: unknown, scenario?: string): unknown {
|
||||
return error instanceof Error
|
||||
? {
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
message:
|
||||
scenario === undefined
|
||||
? error.message
|
||||
: sanitizeReplayText({ text: error.message, scenario }),
|
||||
}
|
||||
: error;
|
||||
}
|
||||
@@ -648,6 +653,13 @@ function sanitizedReplayCwd(scenario: string): string {
|
||||
return `/tmp/claude-replay-${scenario}`;
|
||||
}
|
||||
|
||||
function sanitizeReplayText(input: { readonly text: string; readonly scenario: string }): string {
|
||||
const sanitizedCwd = sanitizedReplayCwd(input.scenario);
|
||||
return [path.resolve(process.cwd(), "../.."), process.cwd()]
|
||||
.toSorted((left, right) => right.length - left.length)
|
||||
.reduce((text, localPath) => text.replaceAll(localPath, sanitizedCwd), input.text);
|
||||
}
|
||||
|
||||
function sanitizeSdkMessageForReplay(input: {
|
||||
readonly message: SDKMessage;
|
||||
readonly scenario: string;
|
||||
@@ -685,6 +697,14 @@ function sanitizeSdkMessageForReplay(input: {
|
||||
},
|
||||
};
|
||||
}
|
||||
if (message.type === "result" && message.subtype !== "success" && message.errors.length > 0) {
|
||||
return {
|
||||
...message,
|
||||
errors: message.errors.map((error) =>
|
||||
sanitizeReplayText({ text: error, scenario: input.scenario }),
|
||||
),
|
||||
};
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
@@ -763,6 +783,81 @@ async function recordMessagesUntilTurnResult(input: {
|
||||
}
|
||||
}
|
||||
|
||||
async function recordMessagesUntilTurnResults(input: {
|
||||
readonly iterator: AsyncIterator<SDKMessage>;
|
||||
readonly entries: Array<ProviderReplayEntry>;
|
||||
readonly scenario: string;
|
||||
readonly resultCount: number;
|
||||
}): Promise<boolean> {
|
||||
let seenResults = 0;
|
||||
while (true) {
|
||||
const next = await input.iterator.next();
|
||||
if (next.done === true) {
|
||||
return false;
|
||||
}
|
||||
const replayMessage = sanitizeSdkMessageForReplay({
|
||||
message: next.value,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
input.entries.push({
|
||||
type: "emit_inbound",
|
||||
label: replayMessage.type,
|
||||
frame: replayMessage,
|
||||
});
|
||||
if (replayMessage.type === "result") {
|
||||
seenResults += 1;
|
||||
if (seenResults >= input.resultCount) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function recordMessagesUntilIteratorDone(input: {
|
||||
readonly iterator: AsyncIterator<SDKMessage>;
|
||||
readonly entries: Array<ProviderReplayEntry>;
|
||||
readonly scenario: string;
|
||||
}): Promise<void> {
|
||||
while (true) {
|
||||
const next = await input.iterator.next();
|
||||
if (next.done === true) {
|
||||
return;
|
||||
}
|
||||
const replayMessage = sanitizeSdkMessageForReplay({
|
||||
message: next.value,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
input.entries.push({
|
||||
type: "emit_inbound",
|
||||
label: replayMessage.type,
|
||||
frame: replayMessage,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function recordFirstInboundMessage(input: {
|
||||
readonly iterator: AsyncIterator<SDKMessage>;
|
||||
readonly entries: Array<ProviderReplayEntry>;
|
||||
readonly scenario: string;
|
||||
}): Promise<void> {
|
||||
const next = await input.iterator.next();
|
||||
if (next.done === true) {
|
||||
throw new Error(`Claude query ended before ${input.scenario} could be interrupted.`);
|
||||
}
|
||||
const replayMessage = sanitizeSdkMessageForReplay({
|
||||
message: next.value,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
input.entries.push({
|
||||
type: "emit_inbound",
|
||||
label: replayMessage.type,
|
||||
frame: replayMessage,
|
||||
});
|
||||
if (replayMessage.type === "result") {
|
||||
throw new Error(`Claude query completed before ${input.scenario} could be interrupted.`);
|
||||
}
|
||||
}
|
||||
|
||||
async function recordClaudeStreamingQuery(input: {
|
||||
readonly scenario: string;
|
||||
readonly prompts: ReadonlyArray<string>;
|
||||
@@ -869,7 +964,142 @@ async function recordClaudeStreamingQuery(input: {
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "error",
|
||||
error: serializeReplayError(error),
|
||||
error: serializeReplayError(error, input.scenario),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function recordClaudeActiveSteeringQuery(input: {
|
||||
readonly scenario: string;
|
||||
readonly prompts: ReadonlyArray<string>;
|
||||
readonly modelSelection: ModelSelection;
|
||||
readonly cwd: string;
|
||||
readonly sessionId: string;
|
||||
readonly entries: Array<ProviderReplayEntry>;
|
||||
readonly enableTools?: boolean;
|
||||
readonly tools?: ClaudeAgentSdkQueryTools;
|
||||
readonly permissionMode?: ClaudeAgentSdkQueryOptions["permissionMode"];
|
||||
readonly allowedTools?: ReadonlyArray<string>;
|
||||
readonly disallowedTools?: ReadonlyArray<string>;
|
||||
readonly allowDangerouslySkipPermissions?: boolean;
|
||||
readonly enablePermissionCallback?: boolean;
|
||||
readonly permissionDecision?: ProviderApprovalDecision;
|
||||
}): Promise<void> {
|
||||
if (input.prompts.length < 2) {
|
||||
throw new Error("Claude active steering replay recording requires at least two prompts.");
|
||||
}
|
||||
|
||||
const promptQueue = new RecordingPromptQueue();
|
||||
const offeredPrompts = new Set<number>();
|
||||
const offerPrompt = (index: number, priority?: SDKUserMessage["priority"]) => {
|
||||
const message = makeClaudeUserMessage({
|
||||
text: input.prompts[index]!,
|
||||
...(priority === undefined ? {} : { priority }),
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: `prompt.offer:${index + 1}`,
|
||||
frame: makeClaudePromptOfferFrame(message),
|
||||
});
|
||||
promptQueue.offer(message);
|
||||
offeredPrompts.add(index);
|
||||
};
|
||||
const offerSteeringPrompts = () => {
|
||||
for (let index = 1; index < input.prompts.length; index += 1) {
|
||||
if (!offeredPrompts.has(index)) {
|
||||
offerPrompt(index, "now");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const canUseTool: CanUseTool | undefined =
|
||||
input.enablePermissionCallback === true
|
||||
? async (toolName, toolInput, callbackOptions) => {
|
||||
const requestFrame = permissionRequestFrame({
|
||||
toolName,
|
||||
toolInput,
|
||||
callbackOptions,
|
||||
});
|
||||
input.entries.push({
|
||||
type: "emit_inbound",
|
||||
label: `permission.request:${toolName}`,
|
||||
frame: requestFrame,
|
||||
});
|
||||
const result = permissionResultForRecording({
|
||||
decision: input.permissionDecision ?? "accept",
|
||||
toolInput,
|
||||
toolUseID: callbackOptions.toolUseID,
|
||||
...(callbackOptions.suggestions === undefined
|
||||
? {}
|
||||
: { suggestions: callbackOptions.suggestions }),
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: `permission.response:${toolName}`,
|
||||
frame: makeClaudePermissionResponseFrame(result),
|
||||
});
|
||||
return result;
|
||||
}
|
||||
: undefined;
|
||||
const options = makeClaudeQueryOptions({
|
||||
modelSelection: input.modelSelection,
|
||||
nativeThreadId: input.sessionId,
|
||||
resume: false,
|
||||
cwd: input.cwd,
|
||||
...(input.enableTools === true
|
||||
? {
|
||||
tools: input.tools ?? { type: "preset", preset: "claude_code" },
|
||||
permissionMode: input.permissionMode ?? "default",
|
||||
...(input.allowedTools === undefined ? {} : { allowedTools: input.allowedTools }),
|
||||
...(input.disallowedTools === undefined
|
||||
? {}
|
||||
: { disallowedTools: input.disallowedTools }),
|
||||
...(input.allowDangerouslySkipPermissions === true
|
||||
? { allowDangerouslySkipPermissions: true }
|
||||
: {}),
|
||||
...(canUseTool === undefined ? {} : { canUseTool }),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "query.open",
|
||||
frame: makeClaudeQueryOpenFrame({ options }),
|
||||
});
|
||||
const queryRuntime = query({
|
||||
prompt: promptQueue,
|
||||
options,
|
||||
});
|
||||
const iterator = queryRuntime[Symbol.asyncIterator]();
|
||||
try {
|
||||
offerPrompt(0);
|
||||
offerSteeringPrompts();
|
||||
const completed = await recordMessagesUntilTurnResults({
|
||||
iterator,
|
||||
entries: input.entries,
|
||||
scenario: input.scenario,
|
||||
resultCount: input.prompts.length,
|
||||
});
|
||||
if (!completed) {
|
||||
throw new Error("Claude active steering query ended before the turn completed.");
|
||||
}
|
||||
if (offeredPrompts.size < input.prompts.length) {
|
||||
throw new Error("Claude active steering prompts were not all offered before completion.");
|
||||
}
|
||||
promptQueue.close();
|
||||
queryRuntime.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
promptQueue.close();
|
||||
queryRuntime.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "error",
|
||||
error: serializeReplayError(error, input.scenario),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
@@ -955,20 +1185,183 @@ async function recordClaudeRestartingQueries(input: {
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "error",
|
||||
error: serializeReplayError(error),
|
||||
error: serializeReplayError(error, input.scenario),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function recordClaudeInterruptRestartQuery(input: {
|
||||
readonly scenario: string;
|
||||
readonly prompts: ReadonlyArray<string>;
|
||||
readonly modelSelection: ModelSelection;
|
||||
readonly cwd: string;
|
||||
readonly sessionId: string;
|
||||
readonly entries: Array<ProviderReplayEntry>;
|
||||
readonly enableTools?: boolean;
|
||||
readonly tools?: ClaudeAgentSdkQueryTools;
|
||||
readonly permissionMode?: ClaudeAgentSdkQueryOptions["permissionMode"];
|
||||
readonly allowedTools?: ReadonlyArray<string>;
|
||||
readonly disallowedTools?: ReadonlyArray<string>;
|
||||
readonly allowDangerouslySkipPermissions?: boolean;
|
||||
}): Promise<void> {
|
||||
if (input.prompts.length !== 2) {
|
||||
throw new Error(
|
||||
`Claude interrupt-restart replay scenario ${input.scenario} requires exactly two prompts.`,
|
||||
);
|
||||
}
|
||||
|
||||
const firstPromptQueue = new RecordingPromptQueue();
|
||||
const firstOptions = makeClaudeQueryOptions({
|
||||
modelSelection: input.modelSelection,
|
||||
nativeThreadId: input.sessionId,
|
||||
resume: false,
|
||||
cwd: input.cwd,
|
||||
...(input.enableTools === true
|
||||
? {
|
||||
tools: input.tools ?? { type: "preset", preset: "claude_code" },
|
||||
permissionMode: input.permissionMode ?? "default",
|
||||
...(input.allowedTools === undefined ? {} : { allowedTools: input.allowedTools }),
|
||||
...(input.disallowedTools === undefined
|
||||
? {}
|
||||
: { disallowedTools: input.disallowedTools }),
|
||||
...(input.allowDangerouslySkipPermissions === true
|
||||
? { allowDangerouslySkipPermissions: true }
|
||||
: {}),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "query.open:1",
|
||||
frame: makeClaudeQueryOpenFrame({ options: firstOptions }),
|
||||
});
|
||||
const firstRuntime = query({
|
||||
prompt: firstPromptQueue,
|
||||
options: firstOptions,
|
||||
});
|
||||
const firstIterator = firstRuntime[Symbol.asyncIterator]();
|
||||
const firstMessage = makeClaudeUserMessage({ text: input.prompts[0]! });
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "prompt.offer:1",
|
||||
frame: makeClaudePromptOfferFrame(firstMessage),
|
||||
});
|
||||
firstPromptQueue.offer(firstMessage);
|
||||
await recordFirstInboundMessage({
|
||||
iterator: firstIterator,
|
||||
entries: input.entries,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "query.interrupt:1",
|
||||
frame: { type: "query.interrupt" },
|
||||
});
|
||||
try {
|
||||
let cancelledError: unknown;
|
||||
try {
|
||||
await firstRuntime.interrupt();
|
||||
} catch (error) {
|
||||
cancelledError = error;
|
||||
}
|
||||
firstPromptQueue.close();
|
||||
try {
|
||||
await recordMessagesUntilIteratorDone({
|
||||
iterator: firstIterator,
|
||||
entries: input.entries,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
} catch (error) {
|
||||
cancelledError = error;
|
||||
}
|
||||
firstRuntime.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: cancelledError === undefined ? "success" : "cancelled",
|
||||
...(cancelledError === undefined
|
||||
? {}
|
||||
: { error: serializeReplayError(cancelledError, input.scenario) }),
|
||||
});
|
||||
} catch (error) {
|
||||
firstPromptQueue.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "error",
|
||||
error: serializeReplayError(error, input.scenario),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
|
||||
const secondPromptQueue = new RecordingPromptQueue();
|
||||
const secondOptions = makeClaudeQueryOptions({
|
||||
modelSelection: input.modelSelection,
|
||||
nativeThreadId: input.sessionId,
|
||||
resume: true,
|
||||
cwd: input.cwd,
|
||||
...(input.enableTools === true
|
||||
? {
|
||||
tools: input.tools ?? { type: "preset", preset: "claude_code" },
|
||||
permissionMode: input.permissionMode ?? "default",
|
||||
...(input.allowedTools === undefined ? {} : { allowedTools: input.allowedTools }),
|
||||
...(input.disallowedTools === undefined
|
||||
? {}
|
||||
: { disallowedTools: input.disallowedTools }),
|
||||
...(input.allowDangerouslySkipPermissions === true
|
||||
? { allowDangerouslySkipPermissions: true }
|
||||
: {}),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "query.open:2",
|
||||
frame: makeClaudeQueryOpenFrame({ options: secondOptions }),
|
||||
});
|
||||
const secondMessage = makeClaudeUserMessage({ text: input.prompts[1]! });
|
||||
input.entries.push({
|
||||
type: "expect_outbound",
|
||||
label: "prompt.offer:2",
|
||||
frame: makeClaudePromptOfferFrame(secondMessage),
|
||||
});
|
||||
|
||||
try {
|
||||
const secondRuntime = query({
|
||||
prompt: secondPromptQueue,
|
||||
options: secondOptions,
|
||||
});
|
||||
secondPromptQueue.offer(secondMessage);
|
||||
secondPromptQueue.close();
|
||||
const secondIterator = secondRuntime[Symbol.asyncIterator]();
|
||||
await recordMessagesUntilIteratorDone({
|
||||
iterator: secondIterator,
|
||||
entries: input.entries,
|
||||
scenario: input.scenario,
|
||||
});
|
||||
secondRuntime.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
secondPromptQueue.close();
|
||||
input.entries.push({
|
||||
type: "runtime_exit",
|
||||
status: "error",
|
||||
error: serializeReplayError(error, input.scenario),
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function recordClaudeAgentSdkReplayTranscript(input: {
|
||||
readonly scenario: string;
|
||||
readonly prompts: ReadonlyArray<string>;
|
||||
readonly modelSelection: ModelSelection;
|
||||
readonly cwd: string;
|
||||
readonly sessionId?: string;
|
||||
readonly queryMode?: "streaming" | "restart";
|
||||
readonly queryMode?: "streaming" | "restart" | "active_steering" | "interrupt_restart";
|
||||
readonly enableTools?: boolean;
|
||||
readonly tools?: ClaudeAgentSdkQueryTools;
|
||||
readonly permissionMode?: ClaudeAgentSdkQueryOptions["permissionMode"];
|
||||
@@ -1010,7 +1403,30 @@ export async function recordClaudeAgentSdkReplayTranscript(input: {
|
||||
? {}
|
||||
: { permissionDecision: input.permissionDecision }),
|
||||
});
|
||||
} else {
|
||||
} else if (queryMode === "active_steering") {
|
||||
await recordClaudeActiveSteeringQuery({
|
||||
scenario: input.scenario,
|
||||
prompts: input.prompts,
|
||||
modelSelection: input.modelSelection,
|
||||
cwd: input.cwd,
|
||||
sessionId,
|
||||
entries,
|
||||
...(input.enableTools === undefined ? {} : { enableTools: input.enableTools }),
|
||||
...(input.tools === undefined ? {} : { tools: input.tools }),
|
||||
...(input.permissionMode === undefined ? {} : { permissionMode: input.permissionMode }),
|
||||
...(input.allowedTools === undefined ? {} : { allowedTools: input.allowedTools }),
|
||||
...(input.disallowedTools === undefined ? {} : { disallowedTools: input.disallowedTools }),
|
||||
...(input.allowDangerouslySkipPermissions === undefined
|
||||
? {}
|
||||
: { allowDangerouslySkipPermissions: input.allowDangerouslySkipPermissions }),
|
||||
...(input.enablePermissionCallback === undefined
|
||||
? {}
|
||||
: { enablePermissionCallback: input.enablePermissionCallback }),
|
||||
...(input.permissionDecision === undefined
|
||||
? {}
|
||||
: { permissionDecision: input.permissionDecision }),
|
||||
});
|
||||
} else if (queryMode === "restart") {
|
||||
await recordClaudeRestartingQueries({
|
||||
scenario: input.scenario,
|
||||
prompts: input.prompts,
|
||||
@@ -1027,6 +1443,23 @@ export async function recordClaudeAgentSdkReplayTranscript(input: {
|
||||
? {}
|
||||
: { allowDangerouslySkipPermissions: input.allowDangerouslySkipPermissions }),
|
||||
});
|
||||
} else {
|
||||
await recordClaudeInterruptRestartQuery({
|
||||
scenario: input.scenario,
|
||||
prompts: input.prompts,
|
||||
modelSelection: input.modelSelection,
|
||||
cwd: input.cwd,
|
||||
sessionId,
|
||||
entries,
|
||||
...(input.enableTools === undefined ? {} : { enableTools: input.enableTools }),
|
||||
...(input.tools === undefined ? {} : { tools: input.tools }),
|
||||
...(input.permissionMode === undefined ? {} : { permissionMode: input.permissionMode }),
|
||||
...(input.allowedTools === undefined ? {} : { allowedTools: input.allowedTools }),
|
||||
...(input.disallowedTools === undefined ? {} : { disallowedTools: input.disallowedTools }),
|
||||
...(input.allowDangerouslySkipPermissions === undefined
|
||||
? {}
|
||||
: { allowDangerouslySkipPermissions: input.allowDangerouslySkipPermissions }),
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -37,6 +37,7 @@ import * as Deferred from "effect/Deferred";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Exit from "effect/Exit";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Path from "effect/Path";
|
||||
import * as Queue from "effect/Queue";
|
||||
import * as Random from "effect/Random";
|
||||
@@ -55,7 +56,7 @@ import {
|
||||
ProviderAdapterResumeThreadError,
|
||||
ProviderAdapterRollbackThreadError,
|
||||
ProviderAdapterRuntimeRequestResponseError,
|
||||
ProviderAdapterSteerRunUnsupportedError,
|
||||
ProviderAdapterSteerRunError,
|
||||
ProviderAdapterTurnStartError,
|
||||
ProviderAdapterV2,
|
||||
type ProviderAdapterV2EnsureThreadInput,
|
||||
@@ -65,6 +66,7 @@ import {
|
||||
type ProviderAdapterV2RuntimePolicy,
|
||||
type ProviderAdapterV2Shape,
|
||||
type ProviderAdapterV2SessionRuntime,
|
||||
type ProviderAdapterV2SteerInput,
|
||||
type ProviderAdapterV2TurnInput,
|
||||
} from "../ProviderAdapter.ts";
|
||||
import {
|
||||
@@ -97,8 +99,8 @@ export const ClaudeProviderCapabilitiesV2 = {
|
||||
emitsTurnStarted: true,
|
||||
emitsTurnCompleted: true,
|
||||
supportsInterrupt: true,
|
||||
supportsActiveSteering: false,
|
||||
supportsSteeringByInterruptRestart: true,
|
||||
supportsActiveSteering: true,
|
||||
supportsSteeringByInterruptRestart: false,
|
||||
supportsQueuedMessages: true,
|
||||
terminalStatusQuality: "strong",
|
||||
},
|
||||
@@ -444,11 +446,6 @@ const getNativeThreadId = Effect.fnUntraced(function* (
|
||||
return nativeThreadId;
|
||||
});
|
||||
|
||||
function shouldResumeClaudeThread(turnInput: ProviderAdapterV2TurnInput): boolean {
|
||||
const firstRunOrdinal = turnInput.providerThread.firstRunOrdinal;
|
||||
return firstRunOrdinal !== null && firstRunOrdinal < turnInput.runOrdinal;
|
||||
}
|
||||
|
||||
export function makeClaudeUserMessage(input: {
|
||||
readonly text: string;
|
||||
readonly priority?: SDKUserMessage["priority"];
|
||||
@@ -1067,6 +1064,10 @@ function terminalStatusFromResult(
|
||||
return "failed";
|
||||
}
|
||||
|
||||
function isClaudeActiveSteeringAbortResult(message: SDKResultMessage): boolean {
|
||||
return message.terminal_reason === "aborted_streaming";
|
||||
}
|
||||
|
||||
function buildAssistantArtifacts(input: {
|
||||
readonly idAllocator: IdAllocatorV2Shape;
|
||||
readonly turnInput: ProviderAdapterV2TurnInput;
|
||||
@@ -1156,6 +1157,7 @@ interface ActiveClaudeTurnContext {
|
||||
readonly input: ProviderAdapterV2TurnInput;
|
||||
readonly nativeTurnId: string;
|
||||
readonly providerTurnId: OrchestrationV2ProviderTurn["id"];
|
||||
readonly providerTurnOrdinal: number;
|
||||
readonly startedAt: DateTime.Utc;
|
||||
readonly assistant: {
|
||||
text: string;
|
||||
@@ -1168,6 +1170,7 @@ interface ClaudeLiveQueryContext {
|
||||
readonly nativeThreadId: string;
|
||||
readonly query: ClaudeAgentSdkQuerySession;
|
||||
readonly queryPolicyKey: string;
|
||||
readonly closed: Deferred.Deferred<void, never>;
|
||||
currentModel: string;
|
||||
}
|
||||
|
||||
@@ -1215,7 +1218,10 @@ export function makeClaudeAdapterV2(
|
||||
const events = yield* Queue.unbounded<ProviderAdapterV2Event>();
|
||||
const activeTurn = yield* Ref.make<ActiveClaudeTurnContext | null>(null);
|
||||
const interruptedTurns = yield* Ref.make(new Set<OrchestrationV2ProviderTurn["id"]>());
|
||||
const steeredTurns = yield* Ref.make(new Set<OrchestrationV2ProviderTurn["id"]>());
|
||||
const queryContext = yield* Ref.make<ClaudeLiveQueryContext | null>(null);
|
||||
const openedNativeThreads = yield* Ref.make(new Set<string>());
|
||||
const nextProviderTurnOrdinals = yield* Ref.make(new Map<string, number>());
|
||||
const itemOrdinals = yield* Ref.make(new Map<string, number>());
|
||||
const nextItemOrdinalsByTurn = yield* Ref.make(new Map<string, number>());
|
||||
const pendingRuntimeRequests = yield* Ref.make(
|
||||
@@ -1266,7 +1272,7 @@ export function makeClaudeAdapterV2(
|
||||
nativeId: input.context.nativeTurnId,
|
||||
strength: "weak",
|
||||
},
|
||||
ordinal: input.context.input.runOrdinal,
|
||||
ordinal: input.context.providerTurnOrdinal,
|
||||
status: input.status,
|
||||
startedAt: input.context.startedAt,
|
||||
completedAt: input.completedAt,
|
||||
@@ -1651,7 +1657,16 @@ export function makeClaudeAdapterV2(
|
||||
}
|
||||
});
|
||||
|
||||
const handleSdkMessage = Effect.fnUntraced(function* (message: SDKMessage) {
|
||||
const handleSdkMessage = Effect.fnUntraced(function* (input: {
|
||||
readonly query: ClaudeAgentSdkQuerySession;
|
||||
readonly message: SDKMessage;
|
||||
}) {
|
||||
const liveQuery = yield* Ref.get(queryContext);
|
||||
if (liveQuery?.query !== input.query) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = input.message;
|
||||
const context = yield* Ref.get(activeTurn);
|
||||
if (context === null) {
|
||||
return;
|
||||
@@ -1710,9 +1725,19 @@ export function makeClaudeAdapterV2(
|
||||
|
||||
if (message.type === "result") {
|
||||
const completedAt = yield* DateTime.now;
|
||||
const interrupted = (yield* Ref.get(interruptedTurns)).has(context.providerTurnId);
|
||||
const wasSteered = (yield* Ref.get(steeredTurns)).has(context.providerTurnId);
|
||||
if (!interrupted && wasSteered && isClaudeActiveSteeringAbortResult(message)) {
|
||||
return;
|
||||
}
|
||||
yield* Ref.update(steeredTurns, (current) => {
|
||||
const next = new Set(current);
|
||||
next.delete(context.providerTurnId);
|
||||
return next;
|
||||
});
|
||||
yield* finalizeActiveTurn({
|
||||
context,
|
||||
status: terminalStatusFromResult(message),
|
||||
status: interrupted ? "interrupted" : terminalStatusFromResult(message),
|
||||
completedAt,
|
||||
});
|
||||
}
|
||||
@@ -1836,7 +1861,15 @@ export function makeClaudeAdapterV2(
|
||||
yield* existing.query.close.pipe(Effect.ignore);
|
||||
}
|
||||
|
||||
const openedWithResume = shouldResumeClaudeThread(turnInput);
|
||||
const openedWithResume = yield* Ref.modify(openedNativeThreads, (current) => {
|
||||
const hasOpenedThread = current.has(nativeThreadId);
|
||||
if (hasOpenedThread) {
|
||||
return [true, current];
|
||||
}
|
||||
const updated = new Set(current);
|
||||
updated.add(nativeThreadId);
|
||||
return [false, updated];
|
||||
});
|
||||
const querySession = yield* queryRunner.open({
|
||||
options: makeClaudeQueryOptions({
|
||||
modelSelection: turnInput.modelSelection,
|
||||
@@ -1856,26 +1889,31 @@ export function makeClaudeAdapterV2(
|
||||
...(shouldInstallClaudePermissionCallback(queryPolicy) ? { canUseTool } : {}),
|
||||
}),
|
||||
});
|
||||
const closed = yield* Deferred.make<void, never>();
|
||||
const context: ClaudeLiveQueryContext = {
|
||||
nativeThreadId,
|
||||
query: querySession,
|
||||
queryPolicyKey,
|
||||
closed,
|
||||
currentModel: turnInput.modelSelection.model,
|
||||
};
|
||||
yield* Ref.set(queryContext, context);
|
||||
yield* querySession.messages.pipe(
|
||||
Stream.runForEach(handleSdkMessage),
|
||||
Stream.runForEach((message) => handleSdkMessage({ query: querySession, message })),
|
||||
Effect.exit,
|
||||
Effect.flatMap(
|
||||
Effect.fnUntraced(function* (exit: ClaudeQueryStreamExit) {
|
||||
yield* Ref.update(queryContext, (current) =>
|
||||
current?.query === querySession ? null : current,
|
||||
);
|
||||
yield* finalizeActiveTurnAfterQueryExit(
|
||||
exit._tag === "Failure" ? exit.cause : undefined,
|
||||
const ownsLiveQuery = yield* Ref.modify(queryContext, (current) =>
|
||||
current?.query === querySession ? [true, null] : [false, current],
|
||||
);
|
||||
if (ownsLiveQuery) {
|
||||
yield* finalizeActiveTurnAfterQueryExit(
|
||||
exit._tag === "Failure" ? exit.cause : undefined,
|
||||
);
|
||||
}
|
||||
}),
|
||||
),
|
||||
Effect.ensuring(Deferred.succeed(closed, undefined)),
|
||||
Effect.forkIn(sessionScope),
|
||||
);
|
||||
return context;
|
||||
@@ -1885,11 +1923,21 @@ export function makeClaudeAdapterV2(
|
||||
function* (turnInput: ProviderAdapterV2TurnInput) {
|
||||
const startedAt = yield* DateTime.now;
|
||||
const nativeThreadId = yield* getNativeThreadId(turnInput.providerThread);
|
||||
const nativeTurnId = `turn:${turnInput.runId}`;
|
||||
const nativeTurnId = `turn:${turnInput.attemptId}`;
|
||||
const providerTurnId = idAllocator.derive.providerTurn({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
nativeTurnId,
|
||||
});
|
||||
const providerTurnOrdinal = yield* Ref.modify(nextProviderTurnOrdinals, (current) => {
|
||||
const previous = current.get(String(turnInput.providerThread.id));
|
||||
const next =
|
||||
previous === undefined
|
||||
? turnInput.runOrdinal
|
||||
: Math.max(previous + 1, turnInput.runOrdinal);
|
||||
const updated = new Map(current);
|
||||
updated.set(String(turnInput.providerThread.id), next);
|
||||
return [next, updated];
|
||||
});
|
||||
const currentTurn = yield* Ref.get(activeTurn);
|
||||
if (currentTurn !== null) {
|
||||
return yield* new ProviderAdapterProtocolError({
|
||||
@@ -1901,6 +1949,7 @@ export function makeClaudeAdapterV2(
|
||||
input: turnInput,
|
||||
nativeTurnId,
|
||||
providerTurnId,
|
||||
providerTurnOrdinal,
|
||||
startedAt,
|
||||
assistant: {
|
||||
text: "",
|
||||
@@ -1947,12 +1996,42 @@ export function makeClaudeAdapterV2(
|
||||
detail: `Claude provider thread ${turnInput.providerThread.id} has no live query.`,
|
||||
});
|
||||
}
|
||||
const currentTurn = yield* Ref.get(activeTurn);
|
||||
if (currentTurn?.providerTurnId !== turnInput.providerTurnId) {
|
||||
return yield* new ProviderAdapterProtocolError({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
detail: `Claude provider turn ${turnInput.providerTurnId} is not the active turn.`,
|
||||
});
|
||||
}
|
||||
yield* Ref.update(interruptedTurns, (current) => {
|
||||
const next = new Set(current);
|
||||
next.add(turnInput.providerTurnId);
|
||||
return next;
|
||||
});
|
||||
yield* existing.query.interrupt;
|
||||
yield* existing.query.close.pipe(Effect.ignore);
|
||||
const closed = yield* Deferred.await(existing.closed).pipe(
|
||||
Effect.timeoutOption("10 seconds"),
|
||||
);
|
||||
if (Option.isSome(closed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const completedAt = yield* DateTime.now;
|
||||
yield* Effect.logWarning("orchestration-v2.claude-query-interrupt-timeout", {
|
||||
providerSessionId: input.providerSessionId,
|
||||
providerThreadId: turnInput.providerThread.id,
|
||||
providerTurnId: turnInput.providerTurnId,
|
||||
});
|
||||
yield* Ref.update(queryContext, (current) =>
|
||||
current?.query === existing.query ? null : current,
|
||||
);
|
||||
yield* finalizeActiveTurn({
|
||||
context: currentTurn,
|
||||
status: "interrupted",
|
||||
completedAt,
|
||||
});
|
||||
yield* Deferred.succeed(existing.closed, undefined);
|
||||
},
|
||||
(effect, turnInput) =>
|
||||
effect.pipe(
|
||||
@@ -1968,6 +2047,45 @@ export function makeClaudeAdapterV2(
|
||||
),
|
||||
);
|
||||
|
||||
const steerTurn = Effect.fn("ClaudeAdapterV2.steerTurn")(
|
||||
function* (turnInput: ProviderAdapterV2SteerInput) {
|
||||
const existing = yield* Ref.get(queryContext);
|
||||
if (existing === null) {
|
||||
return yield* new ProviderAdapterProtocolError({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
detail: `Claude provider thread ${turnInput.providerThread.id} has no live query.`,
|
||||
});
|
||||
}
|
||||
const currentTurn = yield* Ref.get(activeTurn);
|
||||
if (currentTurn?.providerTurnId !== turnInput.providerTurnId) {
|
||||
return yield* new ProviderAdapterProtocolError({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
detail: `Claude provider turn ${turnInput.providerTurnId} is not the active turn.`,
|
||||
});
|
||||
}
|
||||
yield* Ref.update(steeredTurns, (current) => {
|
||||
const next = new Set(current);
|
||||
next.add(turnInput.providerTurnId);
|
||||
return next;
|
||||
});
|
||||
yield* existing.query.offer(
|
||||
makeClaudeUserMessage({ text: turnInput.message.text, priority: "now" }),
|
||||
);
|
||||
},
|
||||
(effect, turnInput) =>
|
||||
effect.pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new ProviderAdapterSteerRunError({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
providerThreadId: turnInput.providerThread.id,
|
||||
providerTurnId: turnInput.providerTurnId,
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const closeSession = Effect.fnUntraced(function* () {
|
||||
const existing = yield* Ref.get(queryContext);
|
||||
if (existing !== null) {
|
||||
@@ -2040,13 +2158,7 @@ export function makeClaudeAdapterV2(
|
||||
),
|
||||
),
|
||||
startTurn,
|
||||
steerTurn: (turnInput) =>
|
||||
Effect.fail(
|
||||
new ProviderAdapterSteerRunUnsupportedError({
|
||||
provider: CLAUDE_PROVIDER,
|
||||
providerThreadId: turnInput.providerThread.id,
|
||||
}),
|
||||
),
|
||||
steerTurn,
|
||||
interruptTurn,
|
||||
respondToRuntimeRequest: Effect.fn("ClaudeAdapterV2.respondToRuntimeRequest")(
|
||||
function* (requestInput) {
|
||||
|
||||
@@ -1099,16 +1099,46 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
|
||||
),
|
||||
);
|
||||
|
||||
const currentAttempt = input.projection.attempts.find(
|
||||
const waitForInterruptedProviderTurn = (
|
||||
attemptsRemaining = 1_000,
|
||||
): Effect.Effect<OrchestrationV2ThreadProjection, OrchestratorV2Error> =>
|
||||
Effect.gen(function* () {
|
||||
const current = yield* projectionStore
|
||||
.getThreadProjection(input.command.threadId)
|
||||
.pipe(
|
||||
Effect.mapError(
|
||||
() => new OrchestratorProjectionError({ threadId: input.command.threadId }),
|
||||
),
|
||||
);
|
||||
const interruptedTurn = current.providerTurns.find(
|
||||
(candidate) => candidate.id === providerTurn.id,
|
||||
);
|
||||
if (interruptedTurn !== undefined && interruptedTurn.status !== "running") {
|
||||
return current;
|
||||
}
|
||||
if (attemptsRemaining <= 0) {
|
||||
return yield* new OrchestratorDispatchError({
|
||||
commandId: input.command.commandId,
|
||||
commandType: input.command.type,
|
||||
cause: `Provider turn ${providerTurn.id} did not terminalize before steering restart.`,
|
||||
});
|
||||
}
|
||||
yield* Effect.yieldNow;
|
||||
return yield* waitForInterruptedProviderTurn(attemptsRemaining - 1);
|
||||
});
|
||||
|
||||
const postInterruptProjection = yield* waitForInterruptedProviderTurn();
|
||||
|
||||
const currentAttempt = postInterruptProjection.attempts.find(
|
||||
(candidate) => candidate.id === targetRun.activeAttemptId,
|
||||
);
|
||||
const currentRootNode = input.projection.nodes.find(
|
||||
const currentRootNode = postInterruptProjection.nodes.find(
|
||||
(candidate) => candidate.id === rootNodeId,
|
||||
);
|
||||
const attemptOrdinal =
|
||||
Math.max(
|
||||
0,
|
||||
...input.projection.attempts
|
||||
...postInterruptProjection.attempts
|
||||
.filter((candidate) => candidate.runId === targetRun.id)
|
||||
.map((candidate) => candidate.attemptOrdinal),
|
||||
) + 1;
|
||||
|
||||
@@ -123,16 +123,10 @@ const scenarioExpectations = {
|
||||
},
|
||||
message_steering: {
|
||||
outgoing: ["initialize", "initialized", "thread/start", "turn/start", "turn/steer"],
|
||||
incoming: [
|
||||
"turn/started",
|
||||
"turn/completed",
|
||||
"item/agentMessage/delta",
|
||||
"item/commandExecution/requestApproval",
|
||||
"serverRequest/resolved",
|
||||
],
|
||||
incoming: ["turn/started", "turn/completed", "item/agentMessage/delta"],
|
||||
turnStartCount: 1,
|
||||
turnCompletedCount: 1,
|
||||
approvalRequestCount: 1,
|
||||
approvalRequestCount: 0,
|
||||
},
|
||||
turn_interrupt: {
|
||||
outgoing: ["initialize", "initialized", "thread/start", "turn/start", "turn/interrupt"],
|
||||
|
||||
@@ -2,6 +2,7 @@ import type {
|
||||
OrchestrationV2Command,
|
||||
OrchestrationV2DomainEvent,
|
||||
OrchestrationV2RuntimeRequest,
|
||||
OrchestrationV2Run,
|
||||
OrchestrationV2ShellSnapshot,
|
||||
OrchestrationV2StoredEvent,
|
||||
OrchestrationV2ThreadProjection,
|
||||
@@ -37,6 +38,11 @@ export type OrchestratorV2ScenarioStep =
|
||||
readonly type: "await_thread_idle";
|
||||
readonly threadId: ThreadId;
|
||||
}
|
||||
| {
|
||||
readonly type: "await_run_steerable";
|
||||
readonly threadId: ThreadId;
|
||||
readonly runId: OrchestrationV2Run["id"];
|
||||
}
|
||||
| {
|
||||
readonly type: "respond_to_next_runtime_request";
|
||||
readonly threadId: ThreadId;
|
||||
@@ -208,6 +214,33 @@ export function runOrchestratorV2Scenario(
|
||||
return yield* waitForThreadIdle(threadId, attemptsRemaining - 1);
|
||||
});
|
||||
|
||||
const waitForRunSteerable = (
|
||||
threadId: ThreadId,
|
||||
runId: OrchestrationV2Run["id"],
|
||||
attemptsRemaining = 1_000,
|
||||
): Effect.Effect<void, OrchestratorV2Error | OrchestratorV2ScenarioStepError, never> =>
|
||||
Effect.gen(function* () {
|
||||
const projection = yield* orchestrator.getThreadProjection(threadId);
|
||||
const run = projection.runs.find((candidate) => candidate.id === runId);
|
||||
const providerTurn = projection.providerTurns.find(
|
||||
(candidate) =>
|
||||
run?.activeAttemptId !== null &&
|
||||
candidate.runAttemptId === run?.activeAttemptId &&
|
||||
candidate.status === "running",
|
||||
);
|
||||
if (run?.status === "running" && providerTurn !== undefined) {
|
||||
return;
|
||||
}
|
||||
if (attemptsRemaining <= 0) {
|
||||
return yield* new OrchestratorV2ScenarioStepError({
|
||||
scenario: scenario.name,
|
||||
step: `await_run_steerable:${runId}`,
|
||||
});
|
||||
}
|
||||
yield* Effect.yieldNow;
|
||||
return yield* waitForRunSteerable(threadId, runId, attemptsRemaining - 1);
|
||||
});
|
||||
|
||||
for (const step of scenarioSteps(scenario)) {
|
||||
switch (step.type) {
|
||||
case "dispatch": {
|
||||
@@ -242,6 +275,9 @@ export function runOrchestratorV2Scenario(
|
||||
case "await_thread_idle":
|
||||
yield* waitForThreadIdle(step.threadId);
|
||||
break;
|
||||
case "await_run_steerable":
|
||||
yield* waitForRunSteerable(step.threadId, step.runId);
|
||||
break;
|
||||
case "respond_to_next_runtime_request": {
|
||||
const request = yield* waitForPendingRuntimeRequest(step.threadId);
|
||||
const result = yield* orchestrator.dispatch({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { assertClaudeMessageSteeringOutput } from "./message_steering/claude_output.ts";
|
||||
import { assertMessageSteeringOutput } from "./message_steering/codex_output.ts";
|
||||
import { messageSteeringInput } from "./message_steering/input.ts";
|
||||
import { assertMultiTurnClaudeOutput } from "./multi_turn/claude_output.ts";
|
||||
@@ -207,6 +208,12 @@ export const ORCHESTRATOR_REPLAY_FIXTURES = [
|
||||
modelSelection: CODEX_MODEL_SELECTION,
|
||||
assertOutput: assertQueuedTurnOutput,
|
||||
},
|
||||
{
|
||||
provider: "claudeAgent",
|
||||
transcriptFile: new URL("./queued_turn/claude_transcript.ndjson", import.meta.url),
|
||||
modelSelection: CLAUDE_MODEL_SELECTION,
|
||||
assertOutput: assertQueuedTurnOutput,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -274,9 +281,14 @@ export const ORCHESTRATOR_REPLAY_FIXTURES = [
|
||||
provider: "codex",
|
||||
transcriptFile: new URL("./message_steering/codex_transcript.ndjson", import.meta.url),
|
||||
modelSelection: CODEX_MODEL_SELECTION,
|
||||
runtimePolicyOverride: READ_ONLY_ON_REQUEST_POLICY,
|
||||
assertOutput: assertMessageSteeringOutput,
|
||||
},
|
||||
{
|
||||
provider: "claudeAgent",
|
||||
transcriptFile: new URL("./message_steering/claude_transcript.ndjson", import.meta.url),
|
||||
modelSelection: CLAUDE_MODEL_SELECTION,
|
||||
assertOutput: assertClaudeMessageSteeringOutput,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -313,10 +325,9 @@ export const ORCHESTRATOR_REPLAY_FIXTURES = [
|
||||
// `tool_call_restricted_granular/claude_transcript.ndjson`, and
|
||||
// docs/orchestration-v2/provider-capability-system.md.
|
||||
|
||||
// TODO(claude-v2/control): add Claude providers to queued-turn, interrupt, and steering fixtures
|
||||
// once the real adapter exposes those behaviors through capability-checked V2 paths.
|
||||
// Cross-reference `queued_turn/codex_transcript.ndjson`, `turn_interrupt/codex_transcript.ndjson`,
|
||||
// `message_steering/codex_transcript.ndjson`, and docs/orchestration-v2/feature-lifecycles.md.
|
||||
// TODO(claude-v2/control): add a Claude interrupt fixture once explicit run interrupt behavior
|
||||
// is fully hardened. Cross-reference `turn_interrupt/codex_transcript.ndjson` and
|
||||
// docs/orchestration-v2/feature-lifecycles.md.
|
||||
|
||||
// TODO(claude-v2/context-transfer): add provider-switch handoff and return fixtures when portable
|
||||
// context handoff is implemented. Cross-reference docs/orchestration-v2/provider-switching-and-context.md
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { assert } from "@effect/vitest";
|
||||
import type { ProviderReplayTranscript } from "@t3tools/contracts";
|
||||
|
||||
import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
|
||||
import {
|
||||
assertAssistantTextIncludes,
|
||||
assertBaseProjection,
|
||||
assertRuntimeRequestCounts,
|
||||
assertSemanticProjectionIntegrity,
|
||||
assertTurnItemTypes,
|
||||
assertUserMessageInputIntents,
|
||||
assertUserMessagesInclude,
|
||||
assertVisibleTurnItemsMirrorLocalTurnItems,
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
projectionFor,
|
||||
} from "../shared.ts";
|
||||
|
||||
export function assertClaudeMessageSteeringOutput(
|
||||
result: OrchestratorV2ScenarioResult,
|
||||
transcript: ProviderReplayTranscript,
|
||||
) {
|
||||
assert.equal(transcript.provider, "claudeAgent");
|
||||
assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] });
|
||||
|
||||
const projection = projectionFor(result, transcript.scenario);
|
||||
assertSemanticProjectionIntegrity(projection);
|
||||
assertVisibleTurnItemsMirrorLocalTurnItems(projection);
|
||||
assertTurnItemTypes(projection, ["user_message", "assistant_message"]);
|
||||
assertRuntimeRequestCounts(projection, { total: 0 });
|
||||
assertUserMessagesInclude(projection, [
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
]);
|
||||
assertUserMessageInputIntents(projection, ["turn_start", "steer"]);
|
||||
assertAssistantTextIncludes(projection, "steering fixture observed");
|
||||
assert.equal(projection.runs.length, 1, "steering must attach to the active run");
|
||||
assert.equal(
|
||||
projection.providerTurns.length,
|
||||
1,
|
||||
"active steering must not create a new provider turn",
|
||||
);
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
{"type":"transcript_start","provider":"claudeAgent","protocol":"claude-agent-sdk.query","version":"0.2.111","scenario":"message_steering","metadata":{"prompts":["Respond with exactly: steering fixture initial response","Actually, respond with exactly: steering fixture observed"],"model":"claude-sonnet-4-6","nativeSessionId":"05f72f7d-81d5-4db9-a3cf-234191cf79f9","queryMode":"active_steering","tools":"claude_code","permissionMode":"bypassPermissions","generatedBy":"recordClaudeAgentSdkReplayTranscript"}}
|
||||
{"type":"expect_outbound","label":"query.open","frame":{"type":"query.open","options":{"model":"claude-sonnet-4-6","tools":{"type":"preset","preset":"claude_code"},"permissionMode":"bypassPermissions","allowDangerouslySkipPermissions":true,"sessionId":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}}
|
||||
{"type":"expect_outbound","label":"prompt.offer:1","frame":{"type":"prompt.offer","message":{"type":"user","message":{"role":"user","content":"Respond with exactly: steering fixture initial response"},"parent_tool_use_id":null}}}
|
||||
{"type":"expect_outbound","label":"prompt.offer:2","frame":{"type":"prompt.offer","message":{"type":"user","message":{"role":"user","content":"Actually, respond with exactly: steering fixture observed"},"parent_tool_use_id":null,"priority":"now"}}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"hook_started","hook_id":"2961831d-241e-47c4-8099-b8779c6b3878","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"d45438eb-d485-490f-9668-a02c5721a6b3","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"hook_response","hook_id":"2961831d-241e-47c4-8099-b8779c6b3878","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"","stdout":"","stderr":"","exit_code":0,"outcome":"success","uuid":"40ef0c52-1168-4049-99af-4c3beb507994","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"init","agents":[],"apiKeySource":"none","claude_code_version":"2.1.111","cwd":"/tmp/claude-replay-message_steering","tools":[],"mcp_servers":[],"model":"claude-sonnet-4-6","permissionMode":"bypassPermissions","slash_commands":[],"output_style":"default","skills":[],"plugins":[],"fast_mode_state":"off","uuid":"71579637-9bc5-4182-b104-4ebb8f2bda0d","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}
|
||||
{"type":"emit_inbound","label":"result","frame":{"type":"result","subtype":"error_during_execution","duration_ms":747,"duration_api_ms":0,"is_error":true,"num_turns":1,"stop_reason":null,"session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9","total_cost_usd":0,"usage":{"input_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":0,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"},"modelUsage":{},"permission_denials":[],"terminal_reason":"aborted_streaming","fast_mode_state":"off","uuid":"781fa8c7-98dd-4679-bb99-82d4c77c9b0c","errors":["[ede_diagnostic] result_type=user last_content_type=n/a stop_reason=null","Error: Request was aborted.\n at vn8 (/tmp/claude-replay-message_steering/node_modules/.bun/@[email protected]+3c5d820c62823f0b/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:5550:1432)\n at next (native:1:11)\n at a85 (/tmp/claude-replay-message_steering/node_modules/.bun/@[email protected]+3c5d820c62823f0b/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:8321:5086)\n at processTicksAndRejections (native:7:39)"]}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"init","agents":[],"apiKeySource":"none","claude_code_version":"2.1.111","cwd":"/tmp/claude-replay-message_steering","tools":[],"mcp_servers":[],"model":"claude-sonnet-4-6","permissionMode":"bypassPermissions","slash_commands":[],"output_style":"default","skills":[],"plugins":[],"fast_mode_state":"off","uuid":"60494b15-57a4-417d-a0d0-0ce42590c36e","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}
|
||||
{"type":"emit_inbound","label":"assistant","frame":{"type":"assistant","message":{"model":"claude-sonnet-4-6","id":"msg_01Cjp5MnmN6F7wwrzNss9zVW","type":"message","role":"assistant","content":[{"type":"text","text":"steering fixture observed"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":2347,"cache_read_input_tokens":9455,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":2347},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"context_management":null},"parent_tool_use_id":null,"session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9","uuid":"2faa9bee-1c72-4b8f-ab04-9796a7ecf6a2"}}
|
||||
{"type":"emit_inbound","label":"rate_limit_event","frame":{"type":"rate_limit_event","rate_limit_info":{"status":"allowed"},"uuid":"b0bfc7e0-1698-4480-821d-16262ceb4448","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9"}}
|
||||
{"type":"emit_inbound","label":"result","frame":{"type":"result","subtype":"success","is_error":false,"api_error_status":null,"duration_ms":3836,"duration_api_ms":1808,"num_turns":1,"result":"steering fixture observed","stop_reason":"end_turn","session_id":"05f72f7d-81d5-4db9-a3cf-234191cf79f9","total_cost_usd":0.01173675,"usage":{"input_tokens":3,"cache_creation_input_tokens":2347,"cache_read_input_tokens":9455,"output_tokens":6,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":2347,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[{"input_tokens":3,"output_tokens":6,"cache_read_input_tokens":9455,"cache_creation_input_tokens":2347,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":2347},"type":"message"}],"speed":"standard"},"modelUsage":{"claude-sonnet-4-6":{"inputTokens":3,"outputTokens":6,"cacheReadInputTokens":9455,"cacheCreationInputTokens":2347,"webSearchRequests":0,"costUSD":0.01173675,"contextWindow":200000,"maxOutputTokens":32000}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","uuid":"7ac0393a-c862-449c-95f7-bbf391264476"}}
|
||||
{"type":"runtime_exit","status":"success"}
|
||||
@@ -3,40 +3,37 @@ import type { ProviderReplayTranscript } from "@t3tools/contracts";
|
||||
|
||||
import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
|
||||
import {
|
||||
assertAllRuntimeRequestsResolved,
|
||||
assertAssistantTextIncludes,
|
||||
assertBaseProjection,
|
||||
assertRuntimeRequestCounts,
|
||||
assertRuntimeRequestKinds,
|
||||
assertSemanticProjectionIntegrity,
|
||||
assertTurnItemTypes,
|
||||
assertUserMessageInputIntents,
|
||||
assertUserMessagesInclude,
|
||||
assertVisibleTurnItemsMirrorLocalTurnItems,
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
projectionFor,
|
||||
TOOL_CALL_WRITE_PROMPT,
|
||||
} from "../shared.ts";
|
||||
|
||||
export function assertMessageSteeringOutput(
|
||||
result: OrchestratorV2ScenarioResult,
|
||||
transcript: ProviderReplayTranscript,
|
||||
) {
|
||||
assert.equal(transcript.provider, "codex");
|
||||
assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] });
|
||||
|
||||
const projection = projectionFor(result, transcript.scenario);
|
||||
assertSemanticProjectionIntegrity(projection);
|
||||
assertVisibleTurnItemsMirrorLocalTurnItems(projection);
|
||||
assertTurnItemTypes(projection, [
|
||||
"user_message",
|
||||
"command_execution",
|
||||
"approval_request",
|
||||
"assistant_message",
|
||||
assertTurnItemTypes(projection, ["user_message", "assistant_message"]);
|
||||
assertRuntimeRequestCounts(projection, { total: 0 });
|
||||
assertUserMessagesInclude(projection, [
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
]);
|
||||
assertRuntimeRequestCounts(projection, { total: 1, resolved: 1 });
|
||||
assertRuntimeRequestKinds(projection, ["command"]);
|
||||
assertAllRuntimeRequestsResolved(projection);
|
||||
assertUserMessagesInclude(projection, [TOOL_CALL_WRITE_PROMPT, MESSAGE_STEERING_STEER_PROMPT]);
|
||||
assertUserMessageInputIntents(projection, ["turn_start", "steer"]);
|
||||
assertAssistantTextIncludes(projection, "steering fixture observed");
|
||||
assert.equal(projection.runs.length, 1, "steering must attach to the active run");
|
||||
assert.equal(
|
||||
projection.providerTurns.length,
|
||||
|
||||
+44
-42
@@ -1,49 +1,51 @@
|
||||
{"type":"transcript_start","provider":"codex","protocol":"codex.app-server","version":"0.120.0","scenario":"message_steering","metadata":{"source":"codex-app-server-probe","fileName":"message_steering.ndjson","description":"One active turn receives an immediate turn/steer request."}}
|
||||
{"type":"transcript_start","provider":"codex","protocol":"codex.app-server","version":"0.128.0","scenario":"message_steering","metadata":{"source":"record-codex-app-server-replay-fixture","fileName":"message_steering.ndjson","description":"One active turn receives an immediate turn/steer request."}}
|
||||
{"type":"expect_outbound","label":"initialize","frame":{"id":1,"method":"initialize","params":{"capabilities":{"experimentalApi":true},"clientInfo":{"name":"t3code_desktop","title":"T3 Code Desktop","version":"0.1.0"}}}}
|
||||
{"type":"emit_inbound","label":"initialize","frame":{"id":1,"result":{"userAgent":"t3code_desktop/0.120.0 (Mac OS 26.4.1; arm64) dumb (t3code_desktop; 0.1.0)","codexHome":"/Users/julius/.codex","platformFamily":"unix","platformOs":"macos"}}}
|
||||
{"type":"emit_inbound","label":"initialize","frame":{"id":1,"result":{"userAgent":"t3code_desktop/0.128.0 (Mac OS 26.4.1; arm64) dumb (t3code_desktop; 0.1.0)","codexHome":"/Users/julius/.codex_p","platformFamily":"unix","platformOs":"macos"}}}
|
||||
{"type":"expect_outbound","label":"initialized","frame":{"method":"initialized"}}
|
||||
{"type":"expect_outbound","label":"thread/start","frame":{"id":2,"method":"thread/start","params":{}}}
|
||||
{"type":"emit_inbound","label":"thread/start","frame":{"id":2,"result":{"thread":{"id":"019dadec-ebd7-75f0-812e-27a7e57bb374","forkedFromId":null,"preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1776739478,"updatedAt":1776739478,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/20/rollout-2026-04-20T19-44-38-019dadec-ebd7-75f0-812e-27a7e57bb374.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","cliVersion":"0.120.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]},"model":"gpt-5.4","modelProvider":"openai","serviceTier":"fast","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":["/Users/julius/.codex/memories"],"readOnlyAccess":{"type":"fullAccess"},"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"reasoningEffort":"xhigh"}}}
|
||||
{"type":"expect_outbound","label":"turn/start","frame":{"id":3,"method":"turn/start","params":{"approvalPolicy":"on-request","input":[{"text":"Create or overwrite .codex-probe-write-action.txt with exactly this text: codex app-server approval fixture. Use a local shell command or file edit only, then briefly report what happened. Do not read package metadata, use GitHub, use web, or use MCP.","type":"text"}],"sandboxPolicy":{"access":{"type":"fullAccess"},"networkAccess":false,"type":"readOnly"},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374"}}}
|
||||
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019dadec-ebd7-75f0-812e-27a7e57bb374","forkedFromId":null,"preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1776739478,"updatedAt":1776739478,"status":{"type":"idle"},"path":"/Users/julius/.codex/sessions/2026/04/20/rollout-2026-04-20T19-44-38-019dadec-ebd7-75f0-812e-27a7e57bb374.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","cliVersion":"0.120.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]}}}}
|
||||
{"type":"emit_inbound","label":"remoteControl/status/changed","frame":{"method":"remoteControl/status/changed","params":{"status":"disabled","environmentId":null}}}
|
||||
{"type":"emit_inbound","label":"thread/start","frame":{"id":2,"result":{"thread":{"id":"019e014d-b214-71f0-9538-23527e8247ca","forkedFromId":null,"preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1778138329,"updatedAt":1778138329,"status":{"type":"idle"},"path":"/Users/julius/.codex_p/sessions/2026/05/07/rollout-2026-05-07T00-18-49-019e014d-b214-71f0-9538-23527e8247ca.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/apps/server","cliVersion":"0.128.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]},"model":"gpt-5.5","modelProvider":"openai","serviceTier":"fast","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/apps/server","instructionSources":["/Users/julius/.codex_p/AGENTS.md","/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/AGENTS.md"],"approvalPolicy":"on-request","approvalsReviewer":"user","sandbox":{"type":"workspaceWrite","writableRoots":["/Users/julius/.codex_p/memories"],"networkAccess":false,"excludeTmpdirEnvVar":false,"excludeSlashTmp":false},"permissionProfile":{"type":"managed","network":{"enabled":false},"fileSystem":{"type":"restricted","entries":[{"path":{"type":"special","value":{"kind":"root"}},"access":"read"},{"path":{"type":"special","value":{"kind":"project_roots","subpath":null}},"access":"write"},{"path":{"type":"special","value":{"kind":"slash_tmp"}},"access":"write"},{"path":{"type":"special","value":{"kind":"tmpdir"}},"access":"write"},{"path":{"type":"special","value":{"kind":"project_roots","subpath":".git"}},"access":"read"},{"path":{"type":"special","value":{"kind":"project_roots","subpath":".agents"}},"access":"read"},{"path":{"type":"special","value":{"kind":"project_roots","subpath":".codex"}},"access":"read"},{"path":{"type":"path","path":"/Users/julius/.codex_p/memories"},"access":"write"}]}},"activePermissionProfile":{"id":":workspace","extends":null,"modifications":[]},"reasoningEffort":"medium"}}}
|
||||
{"type":"expect_outbound","label":"turn/start","frame":{"id":3,"method":"turn/start","params":{"input":[{"text":"Respond with exactly: steering fixture initial response","type":"text"}],"threadId":"019e014d-b214-71f0-9538-23527e8247ca"}}}
|
||||
{"type":"emit_inbound","label":"thread/started","frame":{"method":"thread/started","params":{"thread":{"id":"019e014d-b214-71f0-9538-23527e8247ca","forkedFromId":null,"preview":"","ephemeral":false,"modelProvider":"openai","createdAt":1778138329,"updatedAt":1778138329,"status":{"type":"idle"},"path":"/Users/julius/.codex_p/sessions/2026/05/07/rollout-2026-05-07T00-18-49-019e014d-b214-71f0-9538-23527e8247ca.jsonl","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/apps/server","cliVersion":"0.128.0","source":"vscode","agentNickname":null,"agentRole":null,"gitInfo":null,"name":null,"turns":[]}}}}
|
||||
{"type":"emit_inbound","label":"deprecationNotice","frame":{"method":"deprecationNotice","params":{"summary":"`[features].collab` is deprecated. Use `[features].multi_agent` instead.","details":"Enable it with `--enable multi_agent` or `[features].multi_agent` in config.toml. See https://developers.openai.com/codex/config-basic#feature-flags for details."}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"starting","error":null}}}
|
||||
{"type":"emit_inbound","label":"warning","frame":{"method":"warning","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","message":"Under-development features enabled: apply_patch_freeform. Under-development features are incomplete and may behave unpredictably. To suppress this warning, set `suppress_unstable_features_warning = true` in /Users/julius/.codex_p/config.toml."}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"starting","error":null}}}
|
||||
{"type":"emit_inbound","label":"turn/start","frame":{"id":3,"result":{"turn":{"id":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","status":{"type":"active","activeFlags":[]}}}}
|
||||
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turn":{"id":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","items":[],"status":"inProgress","error":null,"startedAt":1776739478,"completedAt":null,"durationMs":null}}}}
|
||||
{"type":"expect_outbound","label":"turn/steer","frame":{"id":4,"method":"turn/steer","params":{"expectedTurnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","input":[{"text":"Actually, respond with exactly: steering fixture observed","type":"text"}],"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374"}}}
|
||||
{"type":"emit_inbound","label":"turn/steer","frame":{"id":4,"result":{"turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"ready","error":null}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"starting","error":null}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"starting","error":null}}}
|
||||
{"type":"emit_inbound","label":"turn/start","frame":{"id":3,"result":{"turn":{"id":"019e014d-b227-7af1-a889-6c7d828eb1a2","items":[],"status":"inProgress","error":null,"startedAt":null,"completedAt":null,"durationMs":null}}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","status":{"type":"active","activeFlags":[]}}}}
|
||||
{"type":"emit_inbound","label":"turn/started","frame":{"method":"turn/started","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turn":{"id":"019e014d-b227-7af1-a889-6c7d828eb1a2","items":[],"status":"inProgress","error":null,"startedAt":1778138329,"completedAt":null,"durationMs":null}}}}
|
||||
{"type":"expect_outbound","label":"turn/steer","frame":{"id":4,"method":"turn/steer","params":{"expectedTurnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","input":[{"text":"Actually, respond with exactly: steering fixture observed","type":"text"}],"threadId":"019e014d-b214-71f0-9538-23527e8247ca"}}}
|
||||
{"type":"emit_inbound","label":"turn/steer","frame":{"id":4,"result":{"turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"computer-use","status":"ready","error":null}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"uidotsh","status":"ready","error":null}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"550a4417-1843-4e5e-8334-6663461044d5","content":[{"type":"text","text":"Create or overwrite .codex-probe-write-action.txt with exactly this text: codex app-server approval fixture. Use a local shell command or file edit only, then briefly report what happened. Do not read package metadata, use GitHub, use web, or use MCP.","text_elements":[]}]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"550a4417-1843-4e5e-8334-6663461044d5","content":[{"type":"text","text":"Create or overwrite .codex-probe-write-action.txt with exactly this text: codex app-server approval fixture. Use a local shell command or file edit only, then briefly report what happened. Do not read package metadata, use GitHub, use web, or use MCP.","text_elements":[]}]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1776748632},"secondary":{"usedPercent":0,"windowDurationMins":10080,"resetsAt":1777335432},"credits":null,"planType":"pro"}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"reasoning","id":"rs_0a7ba873c300712d0169e6e49aa908819b82a8cc3df84c0036","summary":[],"content":[]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"reasoning","id":"rs_0a7ba873c300712d0169e6e49aa908819b82a8cc3df84c0036","summary":[],"content":[]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","status":{"type":"active","activeFlags":["waitingOnApproval"]}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"commandExecution","id":"call_SkVd4jdkKEnDTMUaNZwexNLm","command":"/bin/zsh -lc \"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt\"","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","processId":null,"source":"agent","status":"inProgress","commandActions":[{"type":"unknown","command":"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt"}],"aggregatedOutput":null,"exitCode":null,"durationMs":null},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/commandExecution/requestApproval","frame":{"method":"item/commandExecution/requestApproval","id":0,"params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","itemId":"call_SkVd4jdkKEnDTMUaNZwexNLm","reason":"Do you want to allow writing the requested fixture file in the workspace?","command":"/bin/zsh -lc \"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt\"","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","commandActions":[{"type":"unknown","command":"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt"}],"proposedExecpolicyAmendment":["/bin/zsh","-lc","printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt"],"availableDecisions":["accept",{"acceptWithExecpolicyAmendment":{"execpolicy_amendment":["/bin/zsh","-lc","printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt"]}},"cancel"]}}}
|
||||
{"type":"expect_outbound","label":"item/commandExecution/requestApproval","frame":{"id":0,"result":{"decision":"accept"}}}
|
||||
{"type":"emit_inbound","label":"serverRequest/resolved","frame":{"method":"serverRequest/resolved","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","requestId":0}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","status":{"type":"active","activeFlags":[]}}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","tokenUsage":{"total":{"totalTokens":28779,"inputTokens":28169,"cachedInputTokens":2432,"outputTokens":610,"reasoningOutputTokens":492},"last":{"totalTokens":28779,"inputTokens":28169,"cachedInputTokens":2432,"outputTokens":610,"reasoningOutputTokens":492},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1776748632},"secondary":{"usedPercent":0,"windowDurationMins":10080,"resetsAt":1777335432},"credits":null,"planType":"pro"}}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"commandExecution","id":"call_SkVd4jdkKEnDTMUaNZwexNLm","command":"/bin/zsh -lc \"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt\"","cwd":"/Users/julius/.t3/worktrees/codething-mvp/t3code-c1e5e1d1/packages/effect-codex-app-server","processId":"78219","source":"unifiedExecStartup","status":"completed","commandActions":[{"type":"unknown","command":"printf '%s' 'codex app-server approval fixture' > .codex-probe-write-action.txt"}],"aggregatedOutput":null,"exitCode":0,"durationMs":0},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"c046f20c-4ec9-4e49-9c31-bcc25ca81b1f","content":[{"type":"text","text":"Actually, respond with exactly: steering fixture observed","text_elements":[]}]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"c046f20c-4ec9-4e49-9c31-bcc25ca81b1f","content":[{"type":"text","text":"Actually, respond with exactly: steering fixture observed","text_elements":[]}]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","tokenUsage":{"total":{"totalTokens":28779,"inputTokens":28169,"cachedInputTokens":2432,"outputTokens":610,"reasoningOutputTokens":492},"last":{"totalTokens":28779,"inputTokens":28169,"cachedInputTokens":2432,"outputTokens":610,"reasoningOutputTokens":492},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1776748632},"secondary":{"usedPercent":0,"windowDurationMins":10080,"resetsAt":1777335432},"credits":null,"planType":"pro"}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"reasoning","id":"rs_0a7ba873c300712d0169e6e4a28490819b9549007ee1031138","summary":[],"content":[]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"reasoning","id":"rs_0a7ba873c300712d0169e6e4a28490819b9549007ee1031138","summary":[],"content":[]},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"agentMessage","id":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","text":"","phase":"final_answer","memoryCitation":null},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","itemId":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","delta":"ste"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","itemId":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","delta":"ering"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","itemId":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","delta":" fixture"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","itemId":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","delta":" observed"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"agentMessage","id":"msg_0a7ba873c300712d0169e6e4a2ba50819ba77e49ab176e7a34","text":"steering fixture observed","phase":"final_answer","memoryCitation":null},"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2"}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turnId":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","tokenUsage":{"total":{"totalTokens":57642,"inputTokens":57006,"cachedInputTokens":30464,"outputTokens":636,"reasoningOutputTokens":508},"last":{"totalTokens":28863,"inputTokens":28837,"cachedInputTokens":28032,"outputTokens":26,"reasoningOutputTokens":16},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":0,"windowDurationMins":300,"resetsAt":1776748632},"secondary":{"usedPercent":0,"windowDurationMins":10080,"resetsAt":1777335432},"credits":null,"planType":"pro"}}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","status":{"type":"idle"}}}}
|
||||
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019dadec-ebd7-75f0-812e-27a7e57bb374","turn":{"id":"019dadec-ebdf-7c22-9dc9-f4d9e4ed2af2","items":[],"status":"completed","error":null,"startedAt":1776739478,"completedAt":1776739490,"durationMs":12401}}}}
|
||||
{"type":"emit_inbound","label":"mcpServer/startupStatus/updated","frame":{"method":"mcpServer/startupStatus/updated","params":{"name":"codex_apps","status":"ready","error":null}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"4fac8685-35e8-475c-96b6-9adb33c68158","content":[{"type":"text","text":"Respond with exactly: steering fixture initial response","text_elements":[]}]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"4fac8685-35e8-475c-96b6-9adb33c68158","content":[{"type":"text","text":"Respond with exactly: steering fixture initial response","text_elements":[]}]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":19,"windowDurationMins":300,"resetsAt":1778142198},"secondary":{"usedPercent":31,"windowDurationMins":10080,"resetsAt":1778539136},"credits":null,"planType":"pro","rateLimitReachedType":null}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"reasoning","id":"rs_010631d904f9e19a0169fc3cdcb670819486fcc6dc7b883f58","summary":[],"content":[]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"reasoning","id":"rs_010631d904f9e19a0169fc3cdcb670819486fcc6dc7b883f58","summary":[],"content":[]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"agentMessage","id":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","text":"","phase":"final_answer","memoryCitation":null},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","delta":"ste"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","delta":"ering"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","delta":" fixture"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","delta":" initial"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","delta":" response"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"agentMessage","id":"msg_010631d904f9e19a0169fc3cdce8ec8194a7d8a5bb50424c09","text":"steering fixture initial response","phase":"final_answer","memoryCitation":null},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","tokenUsage":{"total":{"totalTokens":18900,"inputTokens":18880,"cachedInputTokens":7552,"outputTokens":20,"reasoningOutputTokens":9},"last":{"totalTokens":18900,"inputTokens":18880,"cachedInputTokens":7552,"outputTokens":20,"reasoningOutputTokens":9},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":19,"windowDurationMins":300,"resetsAt":1778142198},"secondary":{"usedPercent":31,"windowDurationMins":10080,"resetsAt":1778539136},"credits":null,"planType":"pro","rateLimitReachedType":null}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"userMessage","id":"3d8198bc-53c8-4885-8dfe-c5158eb2cfb3","content":[{"type":"text","text":"Actually, respond with exactly: steering fixture observed","text_elements":[]}]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"userMessage","id":"3d8198bc-53c8-4885-8dfe-c5158eb2cfb3","content":[{"type":"text","text":"Actually, respond with exactly: steering fixture observed","text_elements":[]}]},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","tokenUsage":{"total":{"totalTokens":18900,"inputTokens":18880,"cachedInputTokens":7552,"outputTokens":20,"reasoningOutputTokens":9},"last":{"totalTokens":18900,"inputTokens":18880,"cachedInputTokens":7552,"outputTokens":20,"reasoningOutputTokens":9},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":19,"windowDurationMins":300,"resetsAt":1778142198},"secondary":{"usedPercent":31,"windowDurationMins":10080,"resetsAt":1778539136},"credits":null,"planType":"pro","rateLimitReachedType":null}}}}
|
||||
{"type":"emit_inbound","label":"item/started","frame":{"method":"item/started","params":{"item":{"type":"agentMessage","id":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","text":"","phase":"final_answer","memoryCitation":null},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","delta":"ste"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","delta":"ering"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","delta":" fixture"}}}
|
||||
{"type":"emit_inbound","label":"item/agentMessage/delta","frame":{"method":"item/agentMessage/delta","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","itemId":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","delta":" observed"}}}
|
||||
{"type":"emit_inbound","label":"item/completed","frame":{"method":"item/completed","params":{"item":{"type":"agentMessage","id":"msg_010631d904f9e19a0169fc3cddd2b08194ba097f57a2fd6332","text":"steering fixture observed","phase":"final_answer","memoryCitation":null},"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2"}}}
|
||||
{"type":"emit_inbound","label":"thread/tokenUsage/updated","frame":{"method":"thread/tokenUsage/updated","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turnId":"019e014d-b227-7af1-a889-6c7d828eb1a2","tokenUsage":{"total":{"totalTokens":37812,"inputTokens":37784,"cachedInputTokens":26368,"outputTokens":28,"reasoningOutputTokens":9},"last":{"totalTokens":18912,"inputTokens":18904,"cachedInputTokens":18816,"outputTokens":8,"reasoningOutputTokens":0},"modelContextWindow":258400}}}}
|
||||
{"type":"emit_inbound","label":"account/rateLimits/updated","frame":{"method":"account/rateLimits/updated","params":{"rateLimits":{"limitId":"codex","limitName":null,"primary":{"usedPercent":19,"windowDurationMins":300,"resetsAt":1778142198},"secondary":{"usedPercent":31,"windowDurationMins":10080,"resetsAt":1778539136},"credits":null,"planType":"pro","rateLimitReachedType":null}}}}
|
||||
{"type":"emit_inbound","label":"thread/status/changed","frame":{"method":"thread/status/changed","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","status":{"type":"idle"}}}}
|
||||
{"type":"emit_inbound","label":"turn/completed","frame":{"method":"turn/completed","params":{"threadId":"019e014d-b214-71f0-9538-23527e8247ca","turn":{"id":"019e014d-b227-7af1-a889-6c7d828eb1a2","items":[],"status":"completed","error":null,"startedAt":1778138329,"completedAt":1778138333,"durationMs":4311}}}}
|
||||
{"type":"runtime_exit","status":"success"}
|
||||
@@ -1,19 +1,18 @@
|
||||
import {
|
||||
MESSAGE_STEERING_INITIAL_PROMPT,
|
||||
MESSAGE_STEERING_STEER_PROMPT,
|
||||
TOOL_CALL_WRITE_PROMPT,
|
||||
type OrchestratorFixtureInput,
|
||||
} from "../shared.ts";
|
||||
|
||||
export function messageSteeringInput(): OrchestratorFixtureInput {
|
||||
return {
|
||||
steps: [
|
||||
{ type: "message", text: TOOL_CALL_WRITE_PROMPT },
|
||||
{ type: "message", text: MESSAGE_STEERING_INITIAL_PROMPT },
|
||||
{
|
||||
type: "steer",
|
||||
text: MESSAGE_STEERING_STEER_PROMPT,
|
||||
targetRunIndex: 1,
|
||||
},
|
||||
{ type: "approve_next_runtime_request" },
|
||||
],
|
||||
};
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{"type":"transcript_start","provider":"claudeAgent","protocol":"claude-agent-sdk.query","version":"0.2.111","scenario":"queued_turn","metadata":{"prompts":["Respond with exactly: first fixture turn complete","Respond with exactly: second fixture turn complete"],"model":"claude-sonnet-4-6","nativeSessionId":"df83c769-3523-4961-95ad-9739bfdf71dd","queryMode":"streaming","tools":"claude_code","permissionMode":"bypassPermissions","generatedBy":"recordClaudeAgentSdkReplayTranscript"}}
|
||||
{"type":"expect_outbound","label":"query.open","frame":{"type":"query.open","options":{"model":"claude-sonnet-4-6","tools":{"type":"preset","preset":"claude_code"},"permissionMode":"bypassPermissions","allowDangerouslySkipPermissions":true,"sessionId":"df83c769-3523-4961-95ad-9739bfdf71dd"}}}
|
||||
{"type":"expect_outbound","label":"prompt.offer:1","frame":{"type":"prompt.offer","message":{"type":"user","message":{"role":"user","content":"Respond with exactly: first fixture turn complete"},"parent_tool_use_id":null}}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"hook_started","hook_id":"cbcb8e66-b64a-49c2-a192-5928cf12f605","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"e1ba5cbc-e83f-452d-a12e-2decc801d1df","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd"}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"hook_response","hook_id":"cbcb8e66-b64a-49c2-a192-5928cf12f605","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"","stdout":"","stderr":"","exit_code":0,"outcome":"success","uuid":"9a8d10e1-b662-44f5-873a-cddcb1f95cd0","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd"}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"init","agents":[],"apiKeySource":"none","claude_code_version":"2.1.111","cwd":"/tmp/claude-replay-queued_turn","tools":[],"mcp_servers":[],"model":"claude-sonnet-4-6","permissionMode":"bypassPermissions","slash_commands":[],"output_style":"default","skills":[],"plugins":[],"fast_mode_state":"off","uuid":"86533c51-7a5a-4034-b94f-12b1b6dd6472","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd"}}
|
||||
{"type":"emit_inbound","label":"assistant","frame":{"type":"assistant","message":{"model":"claude-sonnet-4-6","id":"msg_01NQEE1Hdycdhefjehrr9zcz","type":"message","role":"assistant","content":[{"type":"text","text":"first fixture turn complete"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":2337,"cache_read_input_tokens":9455,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":2337},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"context_management":null},"parent_tool_use_id":null,"session_id":"df83c769-3523-4961-95ad-9739bfdf71dd","uuid":"284c2284-4cd0-4f23-8e0d-32ad924e9227"}}
|
||||
{"type":"emit_inbound","label":"rate_limit_event","frame":{"type":"rate_limit_event","rate_limit_info":{"status":"allowed"},"uuid":"ab9548dc-42c4-4c53-bfb3-765384bd3c8c","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd"}}
|
||||
{"type":"emit_inbound","label":"result","frame":{"type":"result","subtype":"success","is_error":false,"api_error_status":null,"duration_ms":1429,"duration_api_ms":1065,"num_turns":1,"result":"first fixture turn complete","stop_reason":"end_turn","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd","total_cost_usd":0.01171425,"usage":{"input_tokens":3,"cache_creation_input_tokens":2337,"cache_read_input_tokens":9455,"output_tokens":7,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":2337,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[{"input_tokens":3,"output_tokens":7,"cache_read_input_tokens":9455,"cache_creation_input_tokens":2337,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":2337},"type":"message"}],"speed":"standard"},"modelUsage":{"claude-sonnet-4-6":{"inputTokens":3,"outputTokens":7,"cacheReadInputTokens":9455,"cacheCreationInputTokens":2337,"webSearchRequests":0,"costUSD":0.01171425,"contextWindow":200000,"maxOutputTokens":32000}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","uuid":"bd5d5c48-b577-45f8-a0ef-d45fce2ab84d"}}
|
||||
{"type":"expect_outbound","label":"prompt.offer:2","frame":{"type":"prompt.offer","message":{"type":"user","message":{"role":"user","content":"Respond with exactly: second fixture turn complete"},"parent_tool_use_id":null}}}
|
||||
{"type":"emit_inbound","label":"system","frame":{"type":"system","subtype":"init","agents":[],"apiKeySource":"none","claude_code_version":"2.1.111","cwd":"/tmp/claude-replay-queued_turn","tools":[],"mcp_servers":[],"model":"claude-sonnet-4-6","permissionMode":"bypassPermissions","slash_commands":[],"output_style":"default","skills":[],"plugins":[],"fast_mode_state":"off","uuid":"9e812fd7-f51a-49f6-878e-b95360f3da63","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd"}}
|
||||
{"type":"emit_inbound","label":"assistant","frame":{"type":"assistant","message":{"model":"claude-sonnet-4-6","id":"msg_01TLFS8vZYtEwwSUSbBztEFJ","type":"message","role":"assistant","content":[{"type":"text","text":"second fixture turn complete"}],"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":19,"cache_read_input_tokens":11792,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":19},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available"},"context_management":null},"parent_tool_use_id":null,"session_id":"df83c769-3523-4961-95ad-9739bfdf71dd","uuid":"39376d80-6475-4fbc-a95c-b005f83dcfee"}}
|
||||
{"type":"emit_inbound","label":"result","frame":{"type":"result","subtype":"success","is_error":false,"api_error_status":null,"duration_ms":1866,"duration_api_ms":2133,"num_turns":1,"result":"second fixture turn complete","stop_reason":"end_turn","session_id":"df83c769-3523-4961-95ad-9739bfdf71dd","total_cost_usd":0.0154371,"usage":{"input_tokens":3,"cache_creation_input_tokens":19,"cache_read_input_tokens":11792,"output_tokens":7,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":19,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[{"input_tokens":3,"output_tokens":7,"cache_read_input_tokens":11792,"cache_creation_input_tokens":19,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":19},"type":"message"}],"speed":"standard"},"modelUsage":{"claude-sonnet-4-6":{"inputTokens":6,"outputTokens":14,"cacheReadInputTokens":21247,"cacheCreationInputTokens":2356,"webSearchRequests":0,"costUSD":0.0154371,"contextWindow":200000,"maxOutputTokens":32000}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","uuid":"5e21b6c3-b1e0-4d8c-a106-d34a14e941ee"}}
|
||||
{"type":"runtime_exit","status":"success"}
|
||||
@@ -37,6 +37,8 @@ export const TOOL_CALL_READ_ONLY_WORKSPACE_ROOT = "/tmp/claude-replay-tool_call_
|
||||
export const TOOL_CALL_READ_ONLY_PROMPT = `Read ${TOOL_CALL_READ_ONLY_WORKSPACE_ROOT}/package.json and ${TOOL_CALL_READ_ONLY_WORKSPACE_ROOT}/tsconfig.json, then answer exactly: read only tool fixture complete`;
|
||||
export const TOOL_CALL_WRITE_PROMPT =
|
||||
"Create or overwrite .codex-probe-write-action.txt with exactly this text: codex app-server approval fixture. Use a local shell command or file edit only, then briefly report what happened. Do not read package metadata, use GitHub, use web, or use MCP.";
|
||||
export const MESSAGE_STEERING_INITIAL_PROMPT =
|
||||
"Respond with exactly: steering fixture initial response";
|
||||
export const SUBAGENT_PROMPT =
|
||||
"Spawn 2 subagents, one to read package.json and one to read tsconfig.json";
|
||||
export const TURN_INTERRUPT_PROMPT =
|
||||
@@ -296,8 +298,7 @@ export function materializeFixtureInput(input: {
|
||||
const nextStep = input.fixtureInput.steps[stepIndex + 1];
|
||||
const shouldRunInBackground =
|
||||
(nextStep !== undefined &&
|
||||
(((nextStep.type === "steer" || nextStep.type === "interrupt") &&
|
||||
nextStep.targetRunIndex === messageIndex) ||
|
||||
((nextStep.type === "interrupt" && nextStep.targetRunIndex === messageIndex) ||
|
||||
nextStep.type === "queue_message")) ||
|
||||
nextStep?.type === "approve_next_runtime_request" ||
|
||||
nextStep?.type === "answer_next_user_input_request";
|
||||
@@ -321,7 +322,13 @@ export function materializeFixtureInput(input: {
|
||||
);
|
||||
if (shouldRunInBackground) {
|
||||
activeRunDispatchKeys.add(key);
|
||||
} else {
|
||||
} else if (
|
||||
!(
|
||||
nextStep !== undefined &&
|
||||
nextStep.type === "steer" &&
|
||||
nextStep.targetRunIndex === messageIndex
|
||||
)
|
||||
) {
|
||||
steps.push({ type: "await_thread_idle", threadId: ids.threadId });
|
||||
}
|
||||
}
|
||||
@@ -401,6 +408,11 @@ export function materializeFixtureInput(input: {
|
||||
break;
|
||||
case "steer":
|
||||
messageIndex += 1;
|
||||
steps.push({
|
||||
type: "await_run_steerable",
|
||||
threadId: ids.threadId,
|
||||
runId: runIdFor(step.targetRunIndex),
|
||||
});
|
||||
pushDispatch(
|
||||
dispatchMessageCommand({
|
||||
commandId: yield* idAllocator.allocate.command({
|
||||
@@ -421,11 +433,10 @@ export function materializeFixtureInput(input: {
|
||||
},
|
||||
}),
|
||||
);
|
||||
if (
|
||||
input.fixtureInput.steps[stepIndex + 1]?.type !== "approve_next_runtime_request" &&
|
||||
activeRunDispatchKeys.delete(`run:${step.targetRunIndex}`)
|
||||
) {
|
||||
steps.push({ type: "await", key: `run:${step.targetRunIndex}` });
|
||||
if (input.fixtureInput.steps[stepIndex + 1]?.type !== "approve_next_runtime_request") {
|
||||
if (activeRunDispatchKeys.delete(`run:${step.targetRunIndex}`)) {
|
||||
steps.push({ type: "await", key: `run:${step.targetRunIndex}` });
|
||||
}
|
||||
steps.push({ type: "await_thread_idle", threadId: ids.threadId });
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user