Skip to content

fix(drive): recognize current OpenCode title requests - #133

Open
jlongster wants to merge 1 commit into
mainfrom
fix/title-request-detection
Open

jlongster wants to merge 1 commit into
mainfrom
fix/title-request-detection

Conversation

@jlongster

Copy link
Copy Markdown
Collaborator

Problem

isTitleRequest only knew the old title prompts (Generate a title for this conversation: and system You are a title generator.). OpenCode now sends:

  • system: You name conversations so the user can find them later… (packages/core/src/plugin/agent.ts, PROMPT_TITLE)
  • user: Here is the first message of the conversation:\n\n<message>…</message>\n\nReply with only the title., or Here is the conversation so far:… when it regenerates a title (packages/core/src/session/title.ts, messagePrompt / conversationPrompt)

As a result llm.title(...) never fired. Title requests were routed like normal turns: they either took the queued reply or made settlement fail.

Fix

Detect the current system prompt, and also the current user prompt shape (a single user message with one of the two prefixes that ends in Reply with only the title.), so detection still works when the title agent's system prompt is customized. Both old formats keep working.

Verification

  • New test/llm-title.test.ts covers current, customized-system, legacy, and non-title bodies.
  • Ran against opencode2 (v0.0.0-dev-533). I logged the request bodies from a live run, and the first one begins with You name conversations….
    • On main: llm.queue(Llm.text("Hello there.")); ui.submit("Say hi"); ui.waitFor("Hello there.") fails with LlmSettlementError: received 1 unexpected LLM request(s) (or a wait timeout when the title takes the reply).
    • On this branch: a script that calls llm.title(...) and llm.queue(...) runs. The title handler fires, "Hello there." and the generated title both show up, and settlement passes.
  • bun run check and bun run test pass.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant