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("