Skip to content

Commit e83b221

Browse files
tweak: ensure auto continuing compaction is tracked as agent initiated for github copilot (#22567)
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
1 parent 348a849 commit e83b221

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/opencode/src/plugin/github-copilot/copilot.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,15 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
355355
})
356356
.catch(() => undefined)
357357

358-
if (parts?.data.parts?.some((part) => part.type === "compaction")) {
358+
if (
359+
parts?.data.parts?.some(
360+
(part) =>
361+
part.type === "compaction" ||
362+
// Auto-compaction resumes via a synthetic user text part. Treat only
363+
// that marked followup as agent-initiated so manual prompts stay user-initiated.
364+
(part.type === "text" && part.synthetic && part.metadata?.compaction_continue === true),
365+
)
366+
) {
359367
output.headers["x-initiator"] = "agent"
360368
return
361369
}

packages/opencode/src/session/compaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,10 @@ When constructing the summary, try to stick to this template:
345345
messageID: continueMsg.id,
346346
sessionID: input.sessionID,
347347
type: "text",
348+
// Internal marker for auto-compaction followups so provider plugins
349+
// can distinguish them from manual post-compaction user prompts.
350+
// This is not a stable plugin contract and may change or disappear.
351+
metadata: { compaction_continue: true },
348352
synthetic: true,
349353
text,
350354
time: {

packages/opencode/test/session/compaction.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ describe("session.compaction.process", () => {
843843
expect(last?.parts[0]).toMatchObject({
844844
type: "text",
845845
synthetic: true,
846+
metadata: { compaction_continue: true },
846847
})
847848
if (last?.parts[0]?.type === "text") {
848849
expect(last.parts[0].text).toContain("Continue if you have next steps")

0 commit comments

Comments
 (0)