Skip to content

Commit 85cb26f

Browse files
committed
refactor(acp): retain prompt session identity
1 parent f7df713 commit 85cb26f

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎src/main/java/io/github/easy4j/kimi/acp/KimiAcpClient.java‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,14 @@ private String firstText(JsonNode node, String... fields) {
712712
private final class PromptStream {
713713

714714
private final StringBuilder content = new StringBuilder();
715+
private final String sessionId;
715716
private final Consumer<String> onDelta;
716717
private volatile RuntimeException callbackFailure;
717718
private volatile CompletableFuture<KimiAcpTurnResult> turnFuture;
718719
private boolean truncationWarned;
719720

720721
PromptStream(String sessionId, Consumer<String> onDelta) {
722+
this.sessionId = sessionId;
721723
this.onDelta = onDelta;
722724
}
723725

@@ -729,19 +731,10 @@ void cancel() {
729731
CompletableFuture<KimiAcpTurnResult> future = turnFuture;
730732
if (future != null) {
731733
future.completeExceptionally(new KimiException(
732-
"kimi acp session/prompt cancelled: " + sessionId()));
734+
"kimi acp session/prompt cancelled: " + sessionId));
733735
}
734736
}
735737

736-
private String sessionId() {
737-
for (Map.Entry<String, PromptStream> entry : promptStreams.entrySet()) {
738-
if (entry.getValue() == this) {
739-
return entry.getKey();
740-
}
741-
}
742-
return "unknown";
743-
}
744-
745738
void append(String text) {
746739
int cap = config.getMaxContentChars();
747740
String applied = text;

0 commit comments

Comments
 (0)