Skip to content

feat(acp): extract system prompt from synthetic parts in session/prompt#25973

Open
maisonnat wants to merge 1 commit intoanomalyco:devfrom
maisonnat:feat/acp-system-prompt-support
Open

feat(acp): extract system prompt from synthetic parts in session/prompt#25973
maisonnat wants to merge 1 commit intoanomalyco:devfrom
maisonnat:feat/acp-system-prompt-support

Conversation

@maisonnat
Copy link
Copy Markdown

@maisonnat maisonnat commented May 6, 2026

Issue for this PR

Closes # (no related issue — discovered during Hermes Agent ↔ OpenCode ACP integration testing)

Type of change

  • New feature

What does this PR do?

When Claude Code (or Hermes Agent) sends messages via ACP, system messages are formatted as text parts with annotations.audience: ["assistant"]. OpenCode already parses this annotation and marks the part as synthetic, but currently concatenates all parts — including synthetic ones — into a single prompt blob sent to the LLM.

This means system-level instructions get mixed with user messages, losing the separation between "who the AI is" and "what the user asked."

The fix is straightforward: extract synthetic text parts before sending to session.prompt(), concatenate them into a system string, and pass it as the SDK parameter that already exists for this purpose. Non-synthetic parts go into parts as before.

No existing behavior changes — clients that dont use annotations still work identically.

How did you verify your code works?

  • TypeScript compiles cleanly
  • ACP handshake (initialize / session/new) works with stdio transport
  • The synthetic flag is already set by existing annotation parsing code — this just routes it to the right SDK parameter

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

When Hermes Agent sends messages via ACP, it formats system messages
as text parts with annotations.audience: ['assistant']. OpenCode
already marks these as 'synthetic' but concatenated them with user
messages into a single prompt.

This change:
1. Extracts 'synthetic' text parts from the parts array
2. Concatenates them into a 'system' string
3. Passes the 'system' parameter to session.prompt() SDK call
4. Filters synthetic parts from regularParts so the agent sees
   proper separation between system context and user messages

This makes OpenCode ACP compatible with Claude Code's ACP message
format used by tools like Hermes Agent.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

1 participant