fix(agent-manager): keep slow snapshot initialization non-blocking

This commit is contained in:
marius-kilocode
2026-05-29 11:41:13 +02:00
parent 499cd78c0a
commit 2efa216ee5
15 changed files with 132 additions and 27 deletions
+11 -4
View File
@@ -59,6 +59,7 @@ type Input = {
sessionID: SessionID
model: Provider.Model
telemetry?: ReviewTelemetry // kilocode_change
snapshotInitialization?: "wait" // kilocode_change - managed clients wait silently for slow baseline creation
}
export interface Interface {
@@ -121,10 +122,11 @@ export const layer: Layer.Layer<
// Pre-capture snapshot before the LLM stream starts. The AI SDK
// may execute tools internally before emitting start-step events,
// so capturing inside the event handler can be too late.
// kilocode_change start - pass sessionID + messageID so the slow-repo prompt/progress indicator can attach
// kilocode_change start - pass turn context for slow-snapshot UI/policy handling
const initialSnapshot = yield* snapshot.track({
sessionID: input.sessionID,
messageID: input.assistantMessage.id,
snapshotInitialization: input.snapshotInitialization,
})
// kilocode_change end
const ctx: ProcessorContext = {
@@ -505,9 +507,13 @@ export const layer: Layer.Layer<
case "start-step":
ctx.stepStart = performance.now() // kilocode_change
ctx.step = { reasoning: false, text: false, tool: false } // kilocode_change
// kilocode_change start - pass sessionID + messageID so the slow-repo prompt/progress indicator can attach
// kilocode_change start - pass turn context for slow-snapshot UI/policy handling
if (!ctx.snapshot)
ctx.snapshot = yield* snapshot.track({ sessionID: ctx.sessionID, messageID: ctx.assistantMessage.id })
ctx.snapshot = yield* snapshot.track({
sessionID: ctx.sessionID,
messageID: ctx.assistantMessage.id,
snapshotInitialization: input.snapshotInitialization,
})
// kilocode_change end
if (!ctx.assistantMessage.summary) {
// TODO(v2): Temporary dual-write while migrating session messages to v2 events.
@@ -533,10 +539,11 @@ export const layer: Layer.Layer<
return
case "finish-step": {
// kilocode_change start - pass sessionID + messageID
// kilocode_change start - pass turn context for slow-snapshot UI/policy handling
const completedSnapshot = yield* snapshot.track({
sessionID: ctx.sessionID,
messageID: ctx.assistantMessage.id,
snapshotInitialization: input.snapshotInitialization,
})
// kilocode_change end
const usage = Session.getUsage({