Skip to content

Commit 83c1b8d

Browse files
committed
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)
1 parent 56deaa3 commit 83c1b8d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hooks/preemptive-compaction/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,15 @@ export function createPreemptiveCompactionHook(
184184

185185
setTimeout(async () => {
186186
try {
187+
const messageDir = getMessageDir(sessionID)
188+
const storedMessage = messageDir ? findNearestMessageWithFields(messageDir) : null
189+
187190
await ctx.client.session.promptAsync({
188191
path: { id: sessionID },
189-
body: { parts: [{ type: "text", text: "Continue" }] },
192+
body: {
193+
agent: storedMessage?.agent,
194+
parts: [{ type: "text", text: "Continue" }],
195+
},
190196
query: { directory: ctx.directory },
191197
})
192198
} catch {}

0 commit comments

Comments
 (0)