Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/opencode/src/session/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,25 @@ NOTE: At any point in time through this workflow you should feel free to ask the
overflow: task.overflow,
})
if (result === "stop") break
// After compaction, the model loses context about available tools.
// Inject a synthetic user message to re-announce tools on next iteration.
const userMsg: MessageV2.User = {
id: MessageID.ascending(),
sessionID,
role: "user",
time: { created: Date.now() },
agent: lastUser.agent,
model: lastUser.model,
}
yield* sessions.updateMessage(userMsg)
yield* sessions.updatePart({
id: PartID.ascending(),
messageID: userMsg.id,
sessionID,
type: "text",
text: "<system-reminder>Context was compacted. You still have access to all previously available tools and capabilities. Continue with your current task.</system-reminder>",
synthetic: true,
})
continue
}

Expand Down
Loading