fix: synthetic suffix messages break title generation (#15)#34
Merged
Conversation
…neration ACP's message-transform pipeline injects a 'Compressed block context' nudge as a second, standalone user message (createSuffixMessage -> createSyntheticUserMessage). That message's text part lacked the synthetic flag, so OpenCode's SessionPrompt.ensureTitle counted it as a real user message -> its 'filter(real).length !== 1' precondition failed -> title generation was never scheduled (sessions stuck on 'New session - <timestamp>'). createSyntheticUserMessage now marks its text part synthetic: true (matching its name and OpenCode's own synthetic-part convention). ensureTitle excludes all-synthetic user messages, while toModelMessagesEffect still includes synthetic text parts in the LLM call, so the nudge text is still delivered. Refs: GitHub #15 (ranxianglei/opencode-acp)
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.
Problem
opencode-acpprevents OpenCode's built-in session title generation. Sessions stay onNew session - <timestamp>forever. Confirmed still reproducing on 1.5.0 (thanks @kratky-pavel for the detailed repro + logs in #15).Root cause
This is a different path from the
isInternalAgentRequestguard added in #16 (which only handles an internal-agent request flowing throughmessages.transform).OpenCode's
SessionPrompt.ensureTitle(prompt.ts:182) requires exactly one real user message, else it bails (title gen never scheduled):ACP's main-chat message-transform pipeline injects a "Compressed block context…" nudge as a second, standalone user message via
createSuffixMessage→createSyntheticUserMessage(lib/messages/inject/inject.ts:54). That function is namedcreateSyntheticUserMessagebut never set thesyntheticflag on its text part — soensureTitlecounted the nudge as a 2nd real user message →filter(real).length === 2→ precondition failed → title generation was never scheduled (noagent=title/small=truestream appears, because it never starts).Additionally,
title({ history: msgs })isEffect.forkIn(async), sharing the samemsgsarray reference thatmessages.transform(prompt.ts:1574) mutates — a race where the forked title fiber observes the injected 2nd message and bails.Fix
lib/messages/utils.ts—createSyntheticUserMessagenow marks its text partsynthetic: true(matching its name and OpenCode's own convention). One-line, targeted; benefits all callers (the compress nudge viacreateSuffixMessage, andprune.tscompression summaries).Verified safe against OpenCode source:
ensureTitleexcludes all-synthetic user messages → exactly one real user message → title gen runs.MessageV2.toModelMessagesEffect(message-v2.ts:802) includes synthetic text parts (checks onlytype === "text" && !ignored, nosyntheticcheck) → nudge text still delivered to the LLM.isSyntheticMessageuses an ID-prefix check (msg_dcp_summary_), unaffected by thesyntheticfield.Verification
npm run typecheck— PASSnpm test— PASS 487/487 (+1 new contract test replicatingensureTitle'srealfilter), 0 failnpm run build— PASS (325.13 KB)Devlog:
devlog/2026-06-29_synthetic-suffix-fixes-title-gen/(REQ.md + WORKLOG.md).Refs #15.