GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider-acp): reconfigure when approval or sandbox policy changes · pingdotgg/t3code@0f98c52

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/orchestration-v2/Adapters
    • AcpAdapterV2.test.ts
  • packages/provider-acp/src/server
    • adapter.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+63Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,69 @@ describe("AcpAdapterV2", () => {
24512451
}).pipe(Effect.provide(layerTest)),
24522452
);
24532453

2454+
it.live("reconfigures a reused ACP session only when its policy changes", () =>
2455+
Effect.gen(function* () {
2456+
const instanceId = ProviderInstanceId.make("acp-policy-changes");
2457+
const threadId = ThreadId.make("thread-policy-changes");
2458+
const modelSelection = { instanceId, model: "default" };
2459+
let configurations = 0;
2460+
const adapter = yield* makeAcpAdapterV2({
2461+
instanceId,
2462+
selfInvocation: yield* resolveSelfInvocation(),
2463+
flavor: {
2464+
driver: ACP_TEST_DRIVER,
2465+
capabilities: AcpProviderCapabilitiesV2,
2466+
onSessionConfigurationUpdate: () => Effect.sync(() => configurations++),
2467+
makeRuntime: makeMockRuntime({
2468+
childProcessSpawner: yield* ChildProcessSpawner.ChildProcessSpawner,
2469+
mockAgentPath: yield* bundledMockAgentPath,
2470+
}),
2471+
},
2472+
});
2473+
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
2474+
runtimeMode: "approval-required",
2475+
interactionMode: "default",
2476+
cwd: process.cwd(),
2477+
});
2478+
const runtime = yield* adapter.openSession({
2479+
threadId,
2480+
providerSessionId: ProviderSessionId.make("session-policy-changes"),
2481+
modelSelection,
2482+
runtimePolicy,
2483+
});
2484+
const providerThread = yield* runtime.ensureThread({
2485+
threadId,
2486+
modelSelection,
2487+
runtimePolicy,
2488+
});
2489+
const changes = [];
2490+
for (const [ordinal, restrictions] of [
2491+
{ approvalPolicy: "on-request" },
2492+
{ approvalPolicy: "on-request", sandboxPolicy: { type: "readOnly" } },
2493+
{ approvalPolicy: "on-request", sandboxPolicy: { type: "readOnly" } },
2494+
].entries()) {
2495+
const before = configurations;
2496+
yield* runtime.startTurn(
2497+
makeTurnInput({
2498+
threadId,
2499+
providerThread,
2500+
instanceId,
2501+
modelSelection,
2502+
runtimePolicy: { ...runtimePolicy, ...restrictions },
2503+
now: yield* DateTime.now,
2504+
ordinal,
2505+
}),
2506+
);
2507+
yield* runtime.events.pipe(
2508+
Stream.takeUntil((event) => event.type === "turn.terminal"),
2509+
Stream.runDrain,
2510+
);
2511+
changes.push(configurations - before);
2512+
}
2513+
assert.deepEqual(changes, [1, 1, 0], "approval changed, sandbox changed, unchanged");
2514+
}).pipe(Effect.provide(layerTest)),
2515+
);
2516+
24542517
it.live.each(["failed", "recovered", "cancelled"] as const)(
24552518
"projects Mistral retry notices and their %s outcome",
24562519
(outcome) =>
Collapse file

‎packages/provider-acp/src/server/adapter.ts‎

Copy file name to clipboardExpand all lines: packages/provider-acp/src/server/adapter.ts
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,9 +2251,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
22512251
});
22522252
const activeSelection = yield* Ref.make<ModelSelection | null>(null);
22532253
const activeInteractionMode = yield* Ref.make<ProviderInteractionMode | null>(null);
2254-
const configuredRuntimeMode = yield* Ref.make<
2255-
ProviderAdapter.ProviderAdapterV2RuntimePolicy["runtimeMode"] | null
2256-
>(null);
2254+
const configuredRuntimePolicy =
2255+
yield* Ref.make<ProviderAdapter.ProviderAdapterV2RuntimePolicy | null>(null);
22572256
const promptInstructionStates = yield* Ref.make(new Map<string, T3AcpInstructionState>());
22582257
const promptRuntimeInstructions = yield* Ref.make(new Map<string, string>());
22592258
// Unique markers keep delayed prompt completions from clearing later compactions.
@@ -8269,7 +8268,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
82698268
}
82708269
}
82718270
yield* validateModelSelection(modelSelection);
8272-
yield* Ref.set(configuredRuntimeMode, runtimePolicy.runtimeMode);
8271+
yield* Ref.set(configuredRuntimePolicy, runtimePolicy);
82738272
yield* (
82748273
flavor.onSessionConfigurationUpdate?.(
82758274
yield* runtime.getConfigOptions,
@@ -9169,11 +9168,18 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
91699168
} else {
91709169
const configuredSelection = yield* Ref.get(activeSelection);
91719170
const configuredInteractionMode = yield* Ref.get(activeInteractionMode);
9171+
const configuredPolicy = yield* Ref.get(configuredRuntimePolicy);
91729172
if (
91739173
configuredSelection === null ||
91749174
!modelSelectionsEqual(configuredSelection, turnInput.modelSelection) ||
91759175
configuredInteractionMode !== turnInput.runtimePolicy.interactionMode ||
9176-
(yield* Ref.get(configuredRuntimeMode)) !== turnInput.runtimePolicy.runtimeMode
9176+
configuredPolicy === null ||
9177+
configuredPolicy.runtimeMode !== turnInput.runtimePolicy.runtimeMode ||
9178+
!Equal.equals(
9179+
configuredPolicy.approvalPolicy,
9180+
turnInput.runtimePolicy.approvalPolicy,
9181+
) ||
9182+
!Equal.equals(configuredPolicy.sandboxPolicy, turnInput.runtimePolicy.sandboxPolicy)
91779183
) {
91789184
const currentSessionSetup = yield* Ref.get(activeSessionSetup);
91799185
if (currentSessionSetup === null) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.