feat(acp): extract system prompt from synthetic parts in session/prompt#25973
Open
maisonnat wants to merge 1 commit intoanomalyco:devfrom
Open
feat(acp): extract system prompt from synthetic parts in session/prompt#25973maisonnat wants to merge 1 commit intoanomalyco:devfrom
maisonnat wants to merge 1 commit intoanomalyco:devfrom
Conversation
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.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes # (no related issue — discovered during Hermes Agent ↔ OpenCode ACP integration testing)
Type of change
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 assynthetic, 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
synthetictext parts before sending tosession.prompt(), concatenate them into asystemstring, and pass it as the SDK parameter that already exists for this purpose. Non-synthetic parts go intopartsas before.No existing behavior changes — clients that dont use annotations still work identically.
How did you verify your code works?
initialize/session/new) works with stdio transportsyntheticflag is already set by existing annotation parsing code — this just routes it to the right SDK parameterChecklist