fix(todo-continuation-enforcer): tighten post-compaction guard with session-agent fallback
Refine continuation agent resolution to prefer session-state agent fallback while keeping compaction-specific protection. Replace sticky boolean compaction flag with a short-lived timestamp guard so unresolved agents are blocked only during the immediate post-compaction window, avoiding long-lived suppression and preserving existing continuation behavior.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin"
|
||||
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
import { getSessionAgent } from "../../features/claude-code-session-state"
|
||||
import {
|
||||
createInternalAgentTextPart,
|
||||
normalizeSDKResponse,
|
||||
@@ -20,6 +21,7 @@ import {
|
||||
DEFAULT_SKIP_AGENTS,
|
||||
HOOK_NAME,
|
||||
} from "./constants"
|
||||
import { isCompactionGuardActive } from "./compaction-guard"
|
||||
import { getMessageDir } from "./message-directory"
|
||||
import { getIncompleteCount } from "./todo"
|
||||
import type { ResolvedMessageInfo, Todo } from "./types"
|
||||
@@ -88,7 +90,7 @@ export async function injectContinuation(args: {
|
||||
return
|
||||
}
|
||||
|
||||
let agentName = resolvedInfo?.agent
|
||||
let agentName = resolvedInfo?.agent ?? getSessionAgent(sessionID)
|
||||
let model = resolvedInfo?.model
|
||||
let tools = resolvedInfo?.tools
|
||||
|
||||
@@ -122,7 +124,7 @@ export async function injectContinuation(args: {
|
||||
|
||||
if (!agentName) {
|
||||
const compactionState = sessionStateStore.getExistingState(sessionID)
|
||||
if (compactionState?.hasRecentCompaction) {
|
||||
if (compactionState && isCompactionGuardActive(compactionState, Date.now())) {
|
||||
log(`[${HOOK_NAME}] Skipped: agent unknown after compaction`, { sessionID })
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user