From 5660c72e1a428006afc56d105d2b5133d0a3b60a Mon Sep 17 00:00:00 2001 From: matevip Date: Tue, 18 Aug 2026 05:47:48 -0400 Subject: [PATCH] fix(agent): isolate DSH prompt sessions --- .../java/vip/mate/agent/runtime/dsh/DshRuntimeService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mateclaw-server/src/main/java/vip/mate/agent/runtime/dsh/DshRuntimeService.java b/mateclaw-server/src/main/java/vip/mate/agent/runtime/dsh/DshRuntimeService.java index a2b3d795..25d660cb 100644 --- a/mateclaw-server/src/main/java/vip/mate/agent/runtime/dsh/DshRuntimeService.java +++ b/mateclaw-server/src/main/java/vip/mate/agent/runtime/dsh/DshRuntimeService.java @@ -33,6 +33,7 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.UUID; /** * Adapter for the official DeepSeek Harness SDK JSON-RPC runtime. @@ -208,6 +209,10 @@ public class DshRuntimeService implements AgentRuntimeProvider { modelName, Path.of(System.getenv().getOrDefault("DSH_CWD", System.getProperty("user.dir"))), Map.of()); + // Each prompt runs in a fresh child process. DSH persists its + // own session log, so reusing the MateClaw conversation id + // would make the next turn look like a conflicting live session. + String dshSessionId = conversationId + "-" + UUID.randomUUID(); Files.createDirectories(session.workingDirectory()); ModelProviderEntity provider = resolveProvider(modelName); String effectiveModelName = resolveModelName(modelName); @@ -264,7 +269,7 @@ public class DshRuntimeService implements AgentRuntimeProvider { String promptId = "prompt-" + conversationId; send(writer, request("session/prompt", promptId, Map.of( - "sessionId", conversationId, + "sessionId", dshSessionId, "contentBlocks", List.of(Map.of("type", "text", "text", message))))); // DSH may emit session events before the JSON-RPC response