History

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

Julius Marminge committed 6 months ago

Commit e127dfd1 parent a6042da15 files · +837 −126Browse files

Showing the changes to apps/server/scripts (2 of 15 files). Show all

Unified · Split

2 files
  1. apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts +26 −3
  2. apps/server/scripts/record-codex-app-server-replay-fixture.ts +2 −9
apps/server/scripts/record-claude-agent-sdk-replay-fixture.ts+26−3
@@ -14,7 +14,9 @@ import type { RuntimePolicyV2Override } from "../src/orchestration-v2/RuntimePol · 13 unmodified lines
1414 import { makeCheckpointWorkspace } from "../src/orchestration-v2/testkit/ReplayFixtureWorkspace.ts";
1515 import { CLAUDE_MODEL_SELECTION } from "../src/orchestration-v2/testkit/fixtures/shared.ts";
1616 import {
17+ MESSAGE_STEERING_INITIAL_PROMPT,
1718 MULTI_TURN_FIRST_PROMPT,
19+ MESSAGE_STEERING_STEER_PROMPT,
1820 READ_ONLY_NEVER_POLICY,
1921 READ_ONLY_ON_REQUEST_POLICY,
2022 RESTRICTED_GRANULAR_POLICY,
@@ -46,6 +48,18 @@ const CLAUDE_RECORDINGS = { · 25 unmodified lines
4648 queryMode: "restart",
4749 enableTools: true,
4850 },
51+ queued_turn: {
52+ prompts: [MULTI_TURN_FIRST_PROMPT, MULTI_TURN_SECOND_PROMPT],
53+ defaultTranscriptFile: "fixtures/queued_turn/claude_transcript.ndjson",
54+ queryMode: "streaming",
55+ enableTools: true,
56+ },
57+ message_steering: {
58+ prompts: [MESSAGE_STEERING_INITIAL_PROMPT, MESSAGE_STEERING_STEER_PROMPT],
59+ defaultTranscriptFile: "fixtures/message_steering/claude_transcript.ndjson",
60+ queryMode: "active_steering",
61+ enableTools: true,
62+ },
4963 tool_call_read_only: {
5064 prompts: [TOOL_CALL_READ_ONLY_PROMPT],
5165 defaultTranscriptFile: "fixtures/tool_call_read_only/claude_transcript.ndjson",
@@ -88,15 +102,24 @@ function readArgValue(name: string): string | undefined { · 36 unmodified lines
88102 return index >= 0 ? args[index + 1] : undefined;
89103 }
90104
91−function selectedQueryMode(defaultMode: "streaming" | "restart"): "streaming" | "restart" {
105+type ClaudeRecordingQueryMode = "streaming" | "restart" | "active_steering" | "interrupt_restart";
106+
107+function selectedQueryMode(defaultMode: ClaudeRecordingQueryMode): ClaudeRecordingQueryMode {
92108 const raw = readArgValue("--query-mode") ?? process.env.T3_CLAUDE_REPLAY_QUERY_MODE;
93109 if (raw === undefined) {
94110 return defaultMode;
95111 }
96− if (raw === "streaming" || raw === "restart") {
112+ if (
113+ raw === "streaming" ||
114+ raw === "restart" ||
115+ raw === "active_steering" ||
116+ raw === "interrupt_restart"
117+ ) {
97118 return raw;
98119 }
99− throw new Error(`Unsupported Claude replay query mode '${raw}'. Use 'streaming' or 'restart'.`);
120+ throw new Error(
121+ `Unsupported Claude replay query mode '${raw}'. Use 'streaming', 'restart', 'active_steering', or 'interrupt_restart'.`,
122+ );
100123 }
101124
102125 const scenario = readArgValue("--scenario") ?? process.env.T3_CLAUDE_REPLAY_SCENARIO ?? "simple";
apps/server/scripts/record-codex-app-server-replay-fixture.ts+2−9
@@ -8,6 +8,7 @@ import * as CodexClient from "effect-codex-app-server/client"; · 7 unmodified lines
88 import type * as CodexSchema from "effect-codex-app-server/schema";
99
1010 import {
11+ MESSAGE_STEERING_INITIAL_PROMPT,
1112 MESSAGE_STEERING_STEER_PROMPT,
1213 MULTI_TURN_FIRST_PROMPT,
1314 MULTI_TURN_SECOND_PROMPT,
@@ -491,20 +492,12 @@ function scenarios(): ReadonlyArray<ReplayScenario> { · 477 unmodified lines
491492 {
492493 name: "immediate-steer",
493494 description: "Start a turn, then immediately steer the active root turn.",
494− turnDefaults: {
495− approvalPolicy: "never",
496− sandboxPolicy: workspaceWriteSandbox(),
497− },
498495 steps: [
499496 {
500497 type: "steeredTurn",
501498 label: "steered",
502− prompt: TOOL_CALL_WRITE_PROMPT,
499+ prompt: MESSAGE_STEERING_INITIAL_PROMPT,
503500 steer: MESSAGE_STEERING_STEER_PROMPT,
504− turnOverrides: {
505− approvalPolicy: "on-request",
506− sandboxPolicy: readOnlyFullAccessSandbox(),
507− },
508501 },
509502 ],
510503 },