From e8b0a65c6301903956476e590d9976a33253e138 Mon Sep 17 00:00:00 2001 From: Noam Bressler Date: Tue, 20 Jan 2026 18:11:02 +0200 Subject: [PATCH] feat: Support ACP audience by mapping to ignore and synthetic (#9593) Co-authored-by: noam-v --- packages/opencode/src/acp/agent.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/acp/agent.ts b/packages/opencode/src/acp/agent.ts index 6330fae97..9d05a6793 100644 --- a/packages/opencode/src/acp/agent.ts +++ b/packages/opencode/src/acp/agent.ts @@ -12,6 +12,7 @@ import { type PermissionOption, type PlanEntry, type PromptRequest, + type Role, type SetSessionModelRequest, type SetSessionModeRequest, type SetSessionModeResponse, @@ -687,7 +688,12 @@ export namespace ACP { break } } else if (part.type === "text") { - if (part.text && !part.ignored) { + if (part.text) { + const audience: Role[] | undefined = part.synthetic + ? ["assistant"] + : part.ignored + ? ["user"] + : undefined await this.connection .sessionUpdate({ sessionId, @@ -696,6 +702,7 @@ export namespace ACP { content: { type: "text", text: part.text, + ...(audience && { annotations: { audience } }), }, }, }) @@ -968,14 +975,19 @@ export namespace ACP { const agent = session.modeId ?? (await AgentModule.defaultAgent()) const parts: Array< - { type: "text"; text: string } | { type: "file"; url: string; filename: string; mime: string } + { type: "text"; text: string; synthetic?: boolean; ignored?: boolean } | { type: "file"; url: string; filename: string; mime: string } > = [] for (const part of params.prompt) { switch (part.type) { case "text": + const audience = part.annotations?.audience + const forAssistant = audience?.length === 1 && audience[0] === "assistant" + const forUser = audience?.length === 1 && audience[0] === "user" parts.push({ type: "text" as const, text: part.text, + ...(forAssistant && { synthetic: true }), + ...(forUser && { ignored: true }), }) break case "image": {