Propagate runtime approval and sandbox settings to turn startup

- Add `approvalPolicy` and `sandboxMode` to turn-start command and requested payload contracts
- Pass runtime mode-derived values from `ChatView` when dispatching `thread.turn.start`
- Thread provider options through decider/reactor into session startup, with tests updated
This commit is contained in:
Julius Marminge committed 2026-02-26 20:48:18 -08:00
1 parent 4d6e8e1ca5
commit 5d64138a27
6 files changed
+43 -1

No files matched your search

@@ -171,6 +171,8 @@ describe("ProviderCommandReactor", () => {
text: "hello reactor",
attachments: [],
},
approvalPolicy: "on-request",
sandboxMode: "workspace-write",
createdAt: now,
}),
);
@@ -181,6 +183,8 @@ describe("ProviderCommandReactor", () => {
expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({
cwd: "/tmp/provider-project",
model: "gpt-5-codex",
approvalPolicy: "on-request",
sandboxMode: "workspace-write",
});
const readModel = await Effect.runPromise(harness.engine.getReadModel());
@@ -3,7 +3,9 @@ import {
CommandId,
EventId,
type OrchestrationEvent,
type ProviderApprovalPolicy,
type ProviderKind,
type ProviderSandboxMode,
type OrchestrationSession,
type ThreadId,
type TurnId,
@@ -128,6 +130,10 @@ const make = Effect.gen(function* () {
const ensureSessionForThread = Effect.fnUntraced(function* (
threadId: ThreadId,
createdAt: string,
options?: {
readonly approvalPolicy?: ProviderApprovalPolicy;
readonly sandboxMode?: ProviderSandboxMode;
},
) {
const readModel = yield* orchestrationEngine.getReadModel();
const thread = readModel.threads.find((entry) => entry.id === threadId);
@@ -153,6 +159,8 @@ const make = Effect.gen(function* () {
...(preferredProvider ? { provider: preferredProvider } : {}),
...(effectiveCwd ? { cwd: effectiveCwd } : {}),
...(thread.model ? { model: thread.model } : {}),
...(options?.approvalPolicy !== undefined ? { approvalPolicy: options.approvalPolicy } : {}),
...(options?.sandboxMode !== undefined ? { sandboxMode: options.sandboxMode } : {}),
});
yield* setThreadSession({
@@ -180,13 +188,18 @@ const make = Effect.gen(function* () {
readonly attachments?: ReadonlyArray<ChatAttachment>;
readonly model?: string;
readonly effort?: string;
readonly approvalPolicy?: ProviderApprovalPolicy;
readonly sandboxMode?: ProviderSandboxMode;
readonly createdAt: string;
}) {
const thread = yield* resolveThread(input.threadId);
if (!thread) {
return;
}
const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt);
const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt, {
...(input.approvalPolicy !== undefined ? { approvalPolicy: input.approvalPolicy } : {}),
...(input.sandboxMode !== undefined ? { sandboxMode: input.sandboxMode } : {}),
});
const normalizedInput = toNonEmptyProviderInput(input.messageText);
const normalizedAttachments = input.attachments ?? [];
@@ -232,6 +245,8 @@ const make = Effect.gen(function* () {
...(event.payload.model !== undefined ? { model: event.payload.model } : {}),
...(event.payload.effort !== undefined ? { effort: event.payload.effort } : {}),
createdAt: event.payload.createdAt,
approvalPolicy: event.payload.approvalPolicy,
sandboxMode: event.payload.sandboxMode,
});
});
@@ -152,6 +152,8 @@ describe("decider project scripts", () => {
},
model: "gpt-5",
effort: "high",
approvalPolicy: "on-request",
sandboxMode: "workspace-write",
createdAt: now,
},
readModel,
@@ -169,5 +171,13 @@ describe("decider project scripts", () => {
return;
}
expect(turnStartEvent.payload.assistantDeliveryMode).toBe("buffered");
expect(turnStartEvent.payload).toMatchObject({
threadId: ThreadId.makeUnsafe("thread-1"),
messageId: asMessageId("message-user-1"),
model: "gpt-5",
effort: "high",
approvalPolicy: "on-request",
sandboxMode: "workspace-write",
});
});
});
+4
View File
@@ -254,6 +254,10 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
...(command.model !== undefined ? { model: command.model } : {}),
...(command.effort !== undefined ? { effort: command.effort } : {}),
assistantDeliveryMode: command.assistantDeliveryMode ?? DEFAULT_ASSISTANT_DELIVERY_MODE,
...(command.approvalPolicy !== undefined
? { approvalPolicy: command.approvalPolicy }
: {}),
...(command.sandboxMode !== undefined ? { sandboxMode: command.sandboxMode } : {}),
createdAt: command.createdAt,
},
};
+5
View File
@@ -1496,6 +1496,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
),
);
attemptedTurnStart = true;
const approvalPolicy = state.runtimeMode === "full-access" ? "never" : "on-request";
const sandboxMode =
state.runtimeMode === "full-access" ? "danger-full-access" : "workspace-write";
await api.orchestration.dispatchCommand({
type: "thread.turn.start",
commandId: newCommandId(),
@@ -1509,6 +1512,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
model: selectedModel || undefined,
effort: selectedEffort || undefined,
assistantDeliveryMode: settings.enableAssistantStreaming ? "streaming" : "buffered",
approvalPolicy,
sandboxMode,
createdAt: messageCreatedAt,
});
} catch (err) {
+4
View File
@@ -282,6 +282,8 @@ export const ThreadTurnStartCommand = Schema.Struct({
model: Schema.optional(TrimmedNonEmptyString),
effort: Schema.optional(TrimmedNonEmptyString),
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
approvalPolicy: Schema.optional(ProviderApprovalPolicy),
sandboxMode: Schema.optional(ProviderSandboxMode),
createdAt: IsoDateTime,
});
@@ -496,6 +498,8 @@ export const ThreadTurnStartRequestedPayload = Schema.Struct({
model: Schema.optional(TrimmedNonEmptyString),
effort: Schema.optional(TrimmedNonEmptyString),
assistantDeliveryMode: Schema.optional(AssistantDeliveryMode),
approvalPolicy: Schema.optional(ProviderApprovalPolicy),
sandboxMode: Schema.optional(ProviderSandboxMode),
createdAt: IsoDateTime,
});