Skip to content

Session title agent generates title from injected memory/system context rather than actual user message #23114

Description

@marcusyoung

Description

Description

When automatic session title generation runs, it passes the full rendered message history to the title model via MessageV2.toModelMessagesEffect. If a memory MCP server injects prior conversation summaries or facts into the system prompt or as synthetic message parts, the title model receives that injected content and generates a title based on it rather than the actual user message.

Expected Behaviour

The title should reflect the content of the current user message only.

Actual Behaviour

The title reflects injected memory context from prior sessions. Starting a session with "hi" produced:

"Discussion on Workaround and GitHub Issue Regarding Roampal Data Location Setup and Patching cli.py"

— an accurate summary of the previous session's content, surfaced via memory context injection.

Root Cause

In packages/opencode/src/session/prompt.ts, the title generation constructs its payload as:

const context = input.history.slice(0, idx + 1)
messages: [
  { role: "user", content: "Generate a title for this conversation:\n" },
  ...yield* MessageV2.toModelMessagesEffect(context, mdl)
]

MessageV2.toModelMessagesEffect renders the full message including injected memory/system content. The title model then titles based on that rather than the actual user message.

Suggested Fix

Pass only the raw text of the first real user message to the title model:

const userText = firstUser.parts
  .filter(p => p.type === "text")
  .map(p => p.text)
  .join("\n")

messages: [
  { role: "user", content: "Generate a title for this conversation:\n" + userText }
]

This strips all synthetic/injected parts before passing to the title model.

Plugins

roampal-core

OpenCode version

1.4.6

Steps to reproduce

  1. Configure a memory MCP server that injects prior session context into the conversation (e.g. Roampal, mem0, or similar).
  2. Start a new session with a short or unrelated message (e.g. "hi").
  3. Observe that the generated session title reflects content from a previous session rather than the current one.

Screenshot and/or share link

No response

Operating System

Windwos 11

Terminal

PWSH

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions