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:
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user