Skip to content

Document OpenCode prompt format options in ACP handler - #1069

Merged
tbrandenburg merged 2 commits into
mainfrom
copilot/add-code-comment-on-prompt-formats
Feb 3, 2026
Merged

Document OpenCode prompt format options in ACP handler#1069
tbrandenburg merged 2 commits into
mainfrom
copilot/add-code-comment-on-prompt-formats

Conversation

Copilot AI commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

OpenCode accepts two prompt formats per ACP spec. Our codebase uses prompt array format while the PoC used content array format, causing potential confusion.

Changes

Added inline documentation to sendPrompt method clarifying both valid formats:

private async sendPrompt(
  process: ChildProcess,
  sessionId: string,
  content: string
): Promise<unknown> {
  // NOTE: OpenCode supports multiple prompt formats:
  // - prompt: [{ type: 'text', text: '...' }] (our format)
  // - content: [{ role: 'user', content: '...' }] (alternative)
  // Both are valid per ACP spec.
  return this.sendRequest(
    process,
    'session/prompt',
    {
      sessionId,
      prompt: [
        {
          type: 'text',
          text: content,
        },
      ],
    },
    60
  );
}

This comment documents our implementation choice and prevents confusion when comparing against other ACP implementations or the PoC.

Original prompt

Add a code comment explaining that OpenCode supports multiple prompt formats and clarify the team's choice of format. Specifically, the Proof of Concept (PoC) uses the 'content' array format whereas the current implementation uses the 'prompt' array format.

Detailed reference:

The PoC uses:

send('session/prompt', {
  sessionId: sessionId,
  content: [  // PoC uses 'content' array
    {
      role: 'user',
      content: 'Write a hello world program in Python.'
    }
  ]
});

The current implementation uses:

{
  sessionId,
  prompt: [  // We use 'prompt' array
    {
      type: 'text',
      text: content,
    }
  ],
}

Proposed solution:

Include the following comment in acp-handler.ts at the relevant method in the range src/core/target-handlers/acp-handler.ts:198-217:

private async sendPrompt(
  process: ChildProcess,
  sessionId: string,
  content: string
): Promise<unknown> {
  // NOTE: OpenCode supports multiple prompt formats:
  // - prompt: [{ type: 'text', text: '...' }] (our format)
  // - content: [{ role: 'user', content: '...' }] (alternative)
  // Both are valid per ACP spec.
  return this.sendRequest(
    process,
    'session/prompt',
    {
      sessionId,
      prompt: [
        {
          type: 'text',
          text: content,
        },
      ],
    },
    60
  );
}

Please implement this change and address Issue #999.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: tbrandenburg <40181002+tbrandenburg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add code comment explaining prompt format choices for OpenCode Document OpenCode prompt format options in ACP handler Feb 3, 2026
@tbrandenburg
tbrandenburg marked this pull request as ready for review February 3, 2026 09:35
@tbrandenburg
tbrandenburg merged commit 3fb7a17 into main Feb 3, 2026
4 checks passed
@tbrandenburg
tbrandenburg deleted the copilot/add-code-comment-on-prompt-formats branch February 3, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants