From 7ba8e2df9dec79cf4ec4599e0f6f9f0821b3c737 Mon Sep 17 00:00:00 2001 From: Dawid Buszta <344369893+MF-DEEV@users.noreply.github.com> Date: Thu, 22 Oct 2026 11:56:35 +0200 Subject: [PATCH] fix(agents): an idle compaction is not work Claude Code compacts a session left idle on its own and writes the summary as a user line with no reply after it. The AI Agents reader took it for a prompt and showed the session at work for up to an hour; the Sessions reader could too. Both now let it pass. --- .../Vorssaint/Services/AgentUsage/Harness/ClaudeReader.swift | 5 ++++- .../Services/ClaudeSessions/ClaudeTranscriptReader.swift | 3 ++- Tests/ClaudeSessionReaderTests.swift | 2 ++ Tests/HarnessReaderContractTests.swift | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/Vorssaint/Services/AgentUsage/Harness/ClaudeReader.swift b/Sources/Vorssaint/Services/AgentUsage/Harness/ClaudeReader.swift index 98e8ded47..268671fa3 100644 --- a/Sources/Vorssaint/Services/AgentUsage/Harness/ClaudeReader.swift +++ b/Sources/Vorssaint/Services/AgentUsage/Harness/ClaudeReader.swift @@ -53,8 +53,11 @@ struct ClaudeReader: AgentHarnessReader { // A subagent's prompts and tool output never open a turn, and its // tool output can be large: no need to decode it to know that. if AgentLogParser.contains(line, #""isSidechain":true"#) { return [] } + // Claude Code compacts an idle session on its own, writing the summary + // as a user line that no reply follows; it begins no work. guard let json = AgentLogParser.object(line), json["type"] as? String == "user", - json["isMeta"] as? Bool != true, json["isSidechain"] as? Bool != true else { return [] } + json["isMeta"] as? Bool != true, json["isSidechain"] as? Bool != true, + json["isCompactSummary"] as? Bool != true else { return [] } adopt(json, into: &state) state.turnOpen = true state.runningCommands = [] diff --git a/Sources/Vorssaint/Services/ClaudeSessions/ClaudeTranscriptReader.swift b/Sources/Vorssaint/Services/ClaudeSessions/ClaudeTranscriptReader.swift index 0d7e667f5..5b50c4f4a 100644 --- a/Sources/Vorssaint/Services/ClaudeSessions/ClaudeTranscriptReader.swift +++ b/Sources/Vorssaint/Services/ClaudeSessions/ClaudeTranscriptReader.swift @@ -107,7 +107,8 @@ struct ClaudeTranscriptReader { if json["toolEndsTurn"] as? Bool == true { facts.append(.turnEnded(date, completed: true)) } break } - guard json["isMeta"] as? Bool != true else { break } + // The summary an idle compaction writes is no prompt and begins no turn. + guard json["isMeta"] as? Bool != true, json["isCompactSummary"] as? Bool != true else { break } let texts = (content as? String).map { [$0] } ?? blocks.compactMap { $0["type"] as? String == "text" ? $0["text"] as? String : nil } if texts.contains(where: { $0.hasPrefix("[Request interrupted by user") || $0.hasPrefix("