The best way to control Claude Code, Codex and more from any computer or phone
fix(server): keep DeepSeek ACP probes out of session history (#39733)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
cxuan committed
Nov 20, 2026 at 07:34 UTC
31e31c608d33da7755eb331ed214ab42eda29d04
3 files changed
+116
-1
apps/server/src/provider/AcpRegistryProbe.test.ts
+59
@@ -467,6 +467,65 @@ describe("ACP Registry probe", () => {
467
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
468
);
469
470
+ it.live("keeps DeepSeek Harness probe history in a temporary directory", () =>
471
+ Effect.gen(function* () {
472
+ const fs = yield* FileSystem.FileSystem;
473
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "acp-probe-dsh-" });
474
+ const launcher = NodePath.join(directory, "dsh-fixture.mjs");
475
+ const launchLog = NodePath.join(directory, "launch.json");
476
+ yield* fs.writeFileString(
477
+ launcher,
478
+ `
479
+import { readFileSync, writeFileSync } from "node:fs";
480
+import { pathToFileURL } from "node:url";
481
+const [,, agentPath, logPath, ...args] = process.argv;
482
+const patchFlag = args.lastIndexOf("--patch");
483
+const patchPath = patchFlag === -1 ? null : args[patchFlag + 1];
484
+const patch = patchPath === null ? null : JSON.parse(readFileSync(patchPath, "utf8"));
485
+writeFileSync(logPath, JSON.stringify({ args, patch }));
486
+await import(pathToFileURL(agentPath).href);
487
+`,
488
+ );
489
+ const userPatch = NodePath.join(directory, "user-patch.json");
490
+ yield* fs.writeFileString(userPatch, "[]");
491
+ const commandArgs = ["--profile", "acp", "--patch", userPatch];
492
+ const catalog = AcpRegistrySupport.AcpRegistryCatalog.of({
493
+ search: () => Effect.die("unused search"),
494
+ prepare: () => Effect.die("unused prepare"),
495
+ inspect: () => Effect.die("unused inspect"),
496
+ uninstallManagedBinary: () => Effect.die("unused uninstall"),
497
+ resolve: () =>
498
+ Effect.succeed({
499
+ distribution: "local",
500
+ spawn: {
501
+ command: process.execPath,
502
+ args: [launcher, mockAgentPath, launchLog, ...commandArgs],
503
+ },
504
+ }),
505
+ });
506
+ const result = yield* probeAcpRegistryConfiguration({
507
+ instanceId,
508
+ settings: decodeSettings({ source: "local", commandPath: "dsh", commandArgs }),
509
+ cwd: directory,
510
+ environment: process.env,
511
+ }).pipe(Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog));
512
+ expect(result.probe.ready).toBe(true);
513
+ expect(result.probe.models.length).toBeGreaterThan(0);
514
+
515
+ const { args, patch } = JSON.parse(yield* fs.readFileString(launchLog));
516
+ expect(args).toEqual([...commandArgs, "--patch", expect.any(String)]);
517
+ const probeDirectory = NodePath.dirname(args.at(-1));
518
+ expect(patch).toEqual([
519
+ {
520
+ id: "session-persistence-jsonl",
521
+ config: { root: NodePath.join(probeDirectory, "sessions") },
522
+ },
523
+ { id: "session-projection-cache", disabled: true },
524
+ ]);
525
+ expect(yield* fs.exists(probeDirectory)).toBe(false);
526
+ }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
527
+ );
528
+
529
it("distinguishes authentication failures from generic probe failures", () => {
530
const advertised = normalizeAcpRegistryAuthMethods([
531
{ id: "grok-login", name: "Log in with Grok" },
packages/provider-acp-registry/src/server/driver.ts
+6
@@ -18,7 +18,9 @@ import * as SecureRandom from "effect/crypto/SecureRandom";
18
import * as DateTime from "effect/DateTime";
19
import * as Effect from "effect/Effect";
20
import * as Equal from "effect/Equal";
21
+import * as FileSystem from "effect/FileSystem";
22
import * as Option from "effect/Option";
23
+import * as Path from "effect/Path";
24
import * as Ref from "effect/Ref";
25
import * as Result from "effect/Result";
26
import * as Schema from "effect/Schema";
@@ -635,6 +637,8 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
637
}
638
const random = yield* SecureRandom.SecureRandom;
639
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
640
+ const fileSystem = yield* FileSystem.FileSystem;
641
+ const path = yield* Path.Path;
642
const hostEnvironment = yield* HostProcess.Environment;
643
const host = yield* ProviderHost.ProviderHost;
644
const continuationIdentity = defaultProviderContinuationIdentity({
@@ -756,6 +760,8 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
760
).pipe(
761
Effect.provideService(AcpRegistrySupport.AcpRegistryCatalog, catalog),
762
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
763
+ Effect.provideService(FileSystem.FileSystem, fileSystem),
764
+ Effect.provideService(Path.Path, path),
765
Effect.provideService(SecureRandom.SecureRandom, random),
766
);
767
const enrichmentCache = yield* Ref.make<AcpRegistryEnrichmentCache>({
packages/provider-acp-registry/src/server/probe.ts
+51
-1
@@ -16,10 +16,13 @@ import * as SecureRandom from "effect/crypto/SecureRandom";
16
import * as Deferred from "effect/Deferred";
17
import * as Duration from "effect/Duration";
18
import * as Effect from "effect/Effect";
19
+import * as FileSystem from "effect/FileSystem";
20
import * as Layer from "effect/Layer";
21
import * as Option from "effect/Option";
22
+import * as Path from "effect/Path";
23
import * as Ref from "effect/Ref";
24
import * as Result from "effect/Result";
25
+import * as Schema from "effect/Schema";
26
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
27
import type * as EffectAcpErrors from "effect-acp/errors";
28
import type * as EffectAcpSchema from "effect-acp/compat";
@@ -50,6 +53,7 @@ const COMMAND_ADVERTISEMENT_GRACE = "500 millis";
53
// settle it in seconds, not milliseconds; commands arrive much sooner.
54
const MODEL_ADVERTISEMENT_GRACE = "5 seconds";
55
const PROBE_SESSION_DELETE_TIMEOUT = "5 seconds";
56
+const encodeJson = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
57
58
const boundedText = (value: string, maximumLength: number): string =>
59
value.trim().slice(0, maximumLength);
@@ -388,6 +392,37 @@ export type AcpRegistryConfigurationProbe<Requirements = never> = (
392
input: AcpRegistryConfigurationProbeInput,
393
) => Effect.Effect<AcpRegistryConfigurationProbeResult, AcpRegistryOperationError, Requirements>;
394
395
+const isolateDeepSeekProbeHistory = Effect.fn("AcpRegistryProbe.isolateDeepSeekProbeHistory")(
396
+ function* (commandPath: string, spawn: AcpSessionRuntime.AcpSpawnInput) {
397
+ const executable = (commandPath || spawn.command).split(/[\\/]/u).at(-1) ?? "";
398
+ if (!/^dsh(?:\.cmd|\.exe)?$/iu.test(executable)) return spawn;
399
+
400
+ const argumentSeparator = spawn.args.indexOf("--");
401
+ const launcherArgs =
402
+ argumentSeparator === -1 ? spawn.args : spawn.args.slice(0, argumentSeparator);
403
+ const usesAcpProfile =
404
+ launcherArgs[0] === "acp" ||
405
+ launcherArgs.includes("--profile=acp") ||
406
+ launcherArgs.some((arg, index) => arg === "--profile" && launcherArgs[index + 1] === "acp");
407
+ if (!usesAcpProfile) return spawn;
408
+
409
+ // DeepSeek persists session/new before any prompt and does not advertise session/delete.
410
+ const fs = yield* FileSystem.FileSystem;
411
+ const path = yield* Path.Path;
412
+ const directory = yield* fs.makeTempDirectoryScoped({ prefix: "t3-dsh-acp-probe-" });
413
+ const patchPath = path.join(directory, "probe.json");
414
+ const patch = yield* encodeJson([
415
+ { id: "session-persistence-jsonl", config: { root: path.join(directory, "sessions") } },
416
+ { id: "session-projection-cache", disabled: true },
417
+ ]);
418
+ yield* fs.writeFileString(patchPath, patch);
419
+ return {
420
+ ...spawn,
421
+ args: [...launcherArgs, "--patch", patchPath, ...spawn.args.slice(launcherArgs.length)],
422
+ };
423
+ },
424
+);
425
+
426
export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeConfiguration")(
427
function* (
428
input: AcpRegistryConfigurationProbeInput,
@@ -396,6 +431,8 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
431
AcpRegistryOperationError,
432
| AcpRegistrySupport.AcpRegistryCatalog
433
| ChildProcessSpawner.ChildProcessSpawner
434
+ | FileSystem.FileSystem
435
+ | Path.Path
436
| SecureRandom.SecureRandom
437
> {
438
const catalog = yield* AcpRegistrySupport.AcpRegistryCatalog;
@@ -413,6 +450,19 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
450
const resolved = yield* catalog
451
.resolve(input.settings, input.cwd, input.environment)
452
.pipe(Effect.mapError(AcpRegistrySupport.toAcpRegistryOperationError));
453
+ const spawn = yield* isolateDeepSeekProbeHistory(
454
+ input.settings.commandPath,
455
+ resolved.spawn,
456
+ ).pipe(
457
+ Effect.mapError(
458
+ (cause) =>
459
+ new AcpRegistryOperationError({
460
+ reason: "probe_failed",
461
+ message: "Could not prepare temporary history for the DeepSeek Harness probe.",
462
+ cause,
463
+ }),
464
+ ),
465
+ );
466
const authMethodsRef = yield* Ref.make<ReadonlyArray<AcpRegistryProbeAuthMethod>>([]);
467
const authActionRef = yield* Ref.make<AcpRegistryUrlAuthAction | undefined>(undefined);
468
const runtimeCoordinator = yield* Effect.serviceOption(
@@ -420,7 +470,7 @@ export const probeAcpRegistryConfiguration = Effect.fn("AcpRegistryProbe.probeCo
470
);
471
const runtimeContext = yield* Layer.build(
472
AcpSessionRuntime.layer({
423
- spawn: resolved.spawn,
473
+ spawn,
474
cwd: input.cwd,
475
clientCapabilities: {
476
auth: { terminal: Option.isSome(pty) },