Preserve agent context in preemptive compaction's continue message

When sending the 'Continue' message after compaction, now includes the
original agent parameter from the stored message. Previously, the Continue
message was sent without the agent parameter, causing OpenCode to use the
default 'build' agent instead of preserving the original agent context
(e.g., Sisyphus).

Implementation:
- Get messageDir using getMessageDir(sessionID)
- Retrieve storedMessage using findNearestMessageWithFields
- Pass agent: storedMessage?.agent to promptAsync body

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
YeonGyu-Kim
2025-12-23 15:17:51 +09:00
parent b0eb7268f8
commit 10a905ee3f
+7 -1
View File
@@ -184,9 +184,15 @@ export function createPreemptiveCompactionHook(
setTimeout(async () => {
try {
const messageDir = getMessageDir(sessionID)
const storedMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
await ctx.client.session.promptAsync({
path: { id: sessionID },
body: { parts: [{ type: "text", text: "Continue" }] },
body: {
agent: storedMessage?.agent,
parts: [{ type: "text", text: "Continue" }],
},
query: { directory: ctx.directory },
})
} catch {}