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:
parent
1267a1bac5
commit
bd22f1cefe
@ -257,7 +257,7 @@ describe("executeCompact lock management", () => {
|
|||||||
expect(mockClient.session.summarize).toHaveBeenCalledWith(
|
expect(mockClient.session.summarize).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
path: { id: sessionID },
|
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 {
|
try {
|
||||||
await (client as Client).session.prompt_async({
|
await (client as Client).session.prompt_async({
|
||||||
path: { id: sessionID },
|
path: { id: sessionID },
|
||||||
body: { parts: [{ type: "text", text: "Continue" }] },
|
body: { auto: true } as never,
|
||||||
query: { directory },
|
query: { directory },
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
@ -497,21 +497,12 @@ export async function executeCompact(
|
|||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
|
const summarizeBody = { providerID, modelID, auto: true }
|
||||||
await (client as Client).session.summarize({
|
await (client as Client).session.summarize({
|
||||||
path: { id: sessionID },
|
path: { id: sessionID },
|
||||||
body: { providerID, modelID },
|
body: summarizeBody as never,
|
||||||
query: { directory },
|
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;
|
return;
|
||||||
} catch {
|
} catch {
|
||||||
const delay =
|
const delay =
|
||||||
|
|||||||
@ -169,9 +169,10 @@ export function createPreemptiveCompactionHook(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const summarizeBody = { providerID, modelID, auto: true }
|
||||||
await ctx.client.session.summarize({
|
await ctx.client.session.summarize({
|
||||||
path: { id: sessionID },
|
path: { id: sessionID },
|
||||||
body: { providerID, modelID },
|
body: summarizeBody as never,
|
||||||
query: { directory: ctx.directory },
|
query: { directory: ctx.directory },
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -187,22 +188,6 @@ export function createPreemptiveCompactionHook(
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
|
||||||
state.compactionInProgress.delete(sessionID)
|
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
|
return
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log("[preemptive-compaction] compaction failed", { sessionID, error: err })
|
log("[preemptive-compaction] compaction failed", { sessionID, error: err })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user