Skip to content

Commit bd22f1c

Browse files
committed
feat(hooks): use auto flag for session resumption after compaction
- executor.ts: Added `auto: true` to summarize body, removed subsequent prompt_async call - preemptive-compaction/index.ts: Added `auto: true` to summarize body, removed subsequent promptAsync call - executor.test.ts: Updated test expectation to include `auto: true` Instead of sending 'Continue' prompt after compaction, use SessionCompaction's `auto: true` feature which auto-resumes the session. 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent 1267a1b commit bd22f1c

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

src/hooks/anthropic-context-window-limit-recovery/executor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ describe("executeCompact lock management", () => {
257257
expect(mockClient.session.summarize).toHaveBeenCalledWith(
258258
expect.objectContaining({
259259
path: { id: sessionID },
260-
body: { providerID: "anthropic", modelID: "claude-opus-4-5" },
260+
body: { providerID: "anthropic", modelID: "claude-opus-4-5", auto: true },
261261
}),
262262
)
263263

src/hooks/anthropic-context-window-limit-recovery/executor.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export async function executeCompact(
409409
try {
410410
await (client as Client).session.prompt_async({
411411
path: { id: sessionID },
412-
body: { parts: [{ type: "text", text: "Continue" }] },
412+
body: { auto: true } as never,
413413
query: { directory },
414414
});
415415
} catch {}
@@ -497,21 +497,12 @@ export async function executeCompact(
497497
})
498498
.catch(() => {});
499499

500+
const summarizeBody = { providerID, modelID, auto: true }
500501
await (client as Client).session.summarize({
501502
path: { id: sessionID },
502-
body: { providerID, modelID },
503+
body: summarizeBody as never,
503504
query: { directory },
504505
});
505-
506-
setTimeout(async () => {
507-
try {
508-
await (client as Client).session.prompt_async({
509-
path: { id: sessionID },
510-
body: { parts: [{ type: "text", text: "Continue" }] },
511-
query: { directory },
512-
});
513-
} catch {}
514-
}, 500);
515506
return;
516507
} catch {
517508
const delay =

src/hooks/preemptive-compaction/index.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ export function createPreemptiveCompactionHook(
169169
})
170170
}
171171

172+
const summarizeBody = { providerID, modelID, auto: true }
172173
await ctx.client.session.summarize({
173174
path: { id: sessionID },
174-
body: { providerID, modelID },
175+
body: summarizeBody as never,
175176
query: { directory: ctx.directory },
176177
})
177178

@@ -187,22 +188,6 @@ export function createPreemptiveCompactionHook(
187188
.catch(() => {})
188189

189190
state.compactionInProgress.delete(sessionID)
190-
191-
setTimeout(async () => {
192-
try {
193-
const messageDir = getMessageDir(sessionID)
194-
const storedMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
195-
196-
await ctx.client.session.promptAsync({
197-
path: { id: sessionID },
198-
body: {
199-
agent: storedMessage?.agent,
200-
parts: [{ type: "text", text: "Continue" }],
201-
},
202-
query: { directory: ctx.directory },
203-
})
204-
} catch {}
205-
}, 500)
206191
return
207192
} catch (err) {
208193
log("[preemptive-compaction] compaction failed", { sessionID, error: err })

0 commit comments

Comments
 (0)