Repository navigation
Description
Summary
On OpenCode 2.x, prompt-specific recall (Session summary: + Relevant Honcho memory:) is appended to the request as a separate, unframed role: "user" message right after the real user turn. The model cannot tell it apart from something the user typed, so it often starts answering the block instead of the user.
In 0.1.3, recall went through experimental.chat.system.transform (system prompt), and the chat.message hook only captured the prompt. With 0.1.x on OpenCode 1.x we never saw the agent react to the block. After upgrading to OpenCode 2.x and plugin 0.2.1, the agent started commenting on it in most long sessions from the first day.
Environment
@honcho-ai/opencode-honcho0.2.1 (latest on npm). Same code onmainat a181756.- OpenCode 2.2.6 / 2.2.7, Linux.
recallMode: "hybrid",sessionStrategy: "per-directory",observationMode: "unified".- Self-hosted Honcho.
Where it happens
src/v2/runtime.ts:
// session.hook("prompt")
const block = await core.captureUserPrompt(...)
if (block) pendingRecall.set(event.sessionID, block)
// session.hook("context")
const recall = pendingRecall.get(event.sessionID)
if (recall) event.messages.push({ role: "user", content: [{ type: "text", text: recall }] })The 1.x adapter in 0.2.x has a similar shape: chat.message pushes the block as a synthetic: true text part into the user's own message (src/index.ts, around line 2100). OpenCode marks it as synthetic, but the model still receives it as part of the user turn.
The block itself has no framing (formatPromptContextBlock):
sections.push(`Session summary:\n${summary}`)
sections.push(`Relevant Honcho memory:\n${representation}`)
return sections.join("\n\n")The 0.1.4 changelog says "Recalled memory is presented as untrusted reference data", but nothing in the injected text says that it is background context and not part of the user's request.
What we observed
- Each user turn gets about 14.6 KB (~3.6k tokens) of recall in a user-role message. We captured it once by instrumenting
formatPromptContextBlock. - The agent's reasoning repeatedly treats the block as the user's message ("the user's actual message is the one before the injected
Session summary:block"). It spends turns discussing or ignoring the block instead of answering the request. In long sessions this happened dozens of times. - When the session summary itself contains noise, the effect gets worse because the model reads it as user input. In our case the summarizer model had leaked
<think>reasoning into stored summaries. We fixed that on the server side, but the injection channel is what lets that noise reach the model as user input.
Expected
Recall should not be indistinguishable from user input. For example:
- send prompt-specific recall as a system block (as 0.1.x did), or
- if it has to go into the message list, wrap it in an explicit frame (e.g.
<honcho-memory>with a one-line "background reference, not a user request" header), and/or - allow a size cap for the injected summary.
Related
#61 (open) moves the recall right after its prompt instead of the end of event.messages. That fixes the ordering and caching side: in 0.2.1 the block lands after the latest tool result on every step, which looks like the user interrupting mid-task. But it still inserts the recall as an unframed role: "user" message, so this issue remains.
#59 is about the stable snapshot in the system prompt breaking prefix caching. That may be why recall moved out of the system prompt. If so, a framed block may be a middle ground that keeps the cache benefit without the model taking recall for the user's message.
Activity