Title generation runs experimental.chat.system.transform, so plugin-added context is re-sent on every new session
@kitlangton đang làm issue này rồi.
Từ ngày 22/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Description
Session title generation streams the built-in title agent through the same LLMRequestPrep.prepare as chat turns (packages/opencode/src/session/prompt.ts: llm.stream({ agent: title, system: [], small: true, sessionID: <parent session id> })), so experimental.chat.system.transform fires for it. The hook input is { sessionID, model } with the parent's id, so a plugin cannot tell the title request from the first real turn.
Whatever a plugin appends in that hook is therefore sent again in a request whose only output is a short title. With a plugin that appends ~45K tokens of instructions for the main agent, every new session's title call was a 46K-token prompt, ~80s time-to-first-token on a local model, running in parallel with the real first turn. doobidoo/mcp-memory-service injects memories in the same hook keyed only on input.sessionID, so it pays the same.
Proposed fix: do not run experimental.chat.system.transform for the title agent. experimental.chat.messages.transform already never runs for it, and on v2 title generation has its own session.title hook with no agent or tools (#47663, #48212). Users who want a different title prompt have agent: { title: { prompt, model } }, and agent: { title: { disable: true } } still turns the call off.
Why skip the hook rather than make the title request share the main request's cached prefix: what plugins add in this hook differs per user and per plugin, so the title request cannot rely on a matching cached prefix, and the title call's latency and cost still land on every new session. Not running the hook for the title is the smallest change and sends the fewest tokens. I have a one-line PR ready and will open it against this issue.
Related: #23114 (plugin context reaching the title model through messages), #46115 (a redaction plugin wants title requests to run messages.transform), #46371 (title calls billed but absent from session cost).
Plugins
A local plugin that appends project context in experimental.chat.system.transform.
OpenCode version
v1.18.32 (dev @ fe3f3a41f7)
Steps to reproduce
- In an empty directory, save
repro.js:import { appendFileSync } from "node:fs" export default async () => ({ "experimental.chat.system.transform": async (input, output) => { appendFileSync("hook.log", JSON.stringify({ inputKeys: Object.keys(input), sessionID: input.sessionID, system: output.system[0].slice(0, 26) }) + "\n") }, }) opencode.jsonin the same directory:{ "plugin": ["file:///absolute/path/to/repro.js"] }opencode run "hello" </dev/nullhook.loghas two lines with the samesessionIDandinputKeys: ["sessionID","model"]; onesystemis the chat prompt, the other starts withYou are a title generator.Nothing in the input lets the plugin skip the second one.
Screenshot and/or share link
n/a
Operating System
macOS 26.3
Terminal
iTerm2
- Ngôn ngữ chính
- TypeScript
- Star
- 209k
- Fork
- 27.5k
- Merge trung bình
- 9 giờ 42 phút
- Pull request đã merge (30 ngày)
- 389
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Tất cả issue của anomalyco/opencode
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
bcgov/bc-wallet-mobile#4761 · 1 bình luận ·
-
external-issue to-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100