Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions packages/opencode/src/plugin/github-copilot/copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
output.headers["anthropic-beta"] = "interleaved-thinking-2025-05-14"
}

const parts = await sdk.session
const msg = await sdk.session
.message({
path: {
id: incoming.message.sessionID,
Expand All @@ -337,7 +337,13 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
})
.catch(() => undefined)

if (parts?.data.parts?.some((part) => part.type === "compaction")) {
if (
msg?.data?.parts?.some(
(p) =>
p.type === "compaction" ||
(p.type === "text" && p.text === "[auto-compaction-followup]" && p.synthetic && p.ignored),
)
) {
output.headers["x-initiator"] = "agent"
return
}
Expand All @@ -350,11 +356,11 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
query: {
directory: input.directory,
},
throwOnError: true,
})
.catch(() => undefined)
if (!session || !session.data.parentID) return
// mark subagent sessions as agent initiated matching standard that other copilot tools have
if (!session?.data?.parentID) return
const perms = (session.data as typeof session.data & { permission?: Array<{ permission: string }> }).permission
if (perms?.some((r) => r.permission === "user_slash_command")) return
output.headers["x-initiator"] = "agent"
},
}
Expand Down
9 changes: 9 additions & 0 deletions packages/opencode/src/session/compaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@ When constructing the summary, try to stick to this template:
agent: userMessage.agent,
model: userMessage.model,
})
yield* session.updatePart({
id: PartID.ascending(),
messageID: continueMsg.id,
sessionID: input.sessionID,
type: "text",
synthetic: true,
ignored: true,
text: "[auto-compaction-followup]",
})
const text =
(input.overflow
? "The previous request exceeded the provider's size limit due to large media attachments. The conversation was compacted and media files were removed from context. If the user was asking about attached images or files, explain that the attachments were too large to process and suggest they try again with smaller or fewer files.\n\n"
Expand Down
9 changes: 9 additions & 0 deletions packages/opencode/src/tool/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ export const TaskTool = Tool.define(
parentID: ctx.sessionID,
title: params.description + ` (@${next.name} subagent)`,
permission: [
...(params.command
? [
{
permission: "user_slash_command" as const,
pattern: params.command,
action: "allow" as const,
},
]
: []),
...(canTodo
? []
: [
Expand Down
Loading
Loading