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)
This commit is contained in:
@@ -257,7 +257,7 @@ describe("executeCompact lock management", () => {
|
||||
expect(mockClient.session.summarize).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
path: { id: sessionID },
|
||||
body: { providerID: "anthropic", modelID: "claude-opus-4-5" },
|
||||
body: { providerID: "anthropic", modelID: "claude-opus-4-5", auto: true },
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ export async function executeCompact(
|
||||
try {
|
||||
await (client as Client).session.prompt_async({
|
||||
path: { id: sessionID },
|
||||
body: { parts: [{ type: "text", text: "Continue" }] },
|
||||
body: { auto: true } as never,
|
||||
query: { directory },
|
||||
});
|
||||
} catch {}
|
||||
@@ -497,21 +497,12 @@ export async function executeCompact(
|
||||
})
|
||||
.catch(() => {});
|
||||
|
||||
const summarizeBody = { providerID, modelID, auto: true }
|
||||
await (client as Client).session.summarize({
|
||||
path: { id: sessionID },
|
||||
body: { providerID, modelID },
|
||||
body: summarizeBody as never,
|
||||
query: { directory },
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
await (client as Client).session.prompt_async({
|
||||
path: { id: sessionID },
|
||||
body: { parts: [{ type: "text", text: "Continue" }] },
|
||||
query: { directory },
|
||||
});
|
||||
} catch {}
|
||||
}, 500);
|
||||
return;
|
||||
} catch {
|
||||
const delay =
|
||||
|
||||
@@ -169,9 +169,10 @@ export function createPreemptiveCompactionHook(
|
||||
})
|
||||
}
|
||||
|
||||
const summarizeBody = { providerID, modelID, auto: true }
|
||||
await ctx.client.session.summarize({
|
||||
path: { id: sessionID },
|
||||
body: { providerID, modelID },
|
||||
body: summarizeBody as never,
|
||||
query: { directory: ctx.directory },
|
||||
})
|
||||
|
||||
@@ -187,22 +188,6 @@ export function createPreemptiveCompactionHook(
|
||||
.catch(() => {})
|
||||
|
||||
state.compactionInProgress.delete(sessionID)
|
||||
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const messageDir = getMessageDir(sessionID)
|
||||
const storedMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
|
||||
|
||||
await ctx.client.session.promptAsync({
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: storedMessage?.agent,
|
||||
parts: [{ type: "text", text: "Continue" }],
|
||||
},
|
||||
query: { directory: ctx.directory },
|
||||
})
|
||||
} catch {}
|
||||
}, 500)
|
||||
return
|
||||
} catch (err) {
|
||||
log("[preemptive-compaction] compaction failed", { sessionID, error: err })
|
||||
|
||||
Reference in New Issue
Block a user