Skip to content

fix(core): retry session title after failed first step #39529

Closed

Description

@kitlangton

Problem

A V2 session can remain permanently named New session - ... when its initial model step fails and another user message is admitted before a later step succeeds.

Title generation currently starts only after runStep completes successfully. Once it eventually starts, SessionHistory.firstUserMessageIfOnly declines to provide the first message if more than one user message now exists. The title attempt then returns silently and is not retried.

Reproduction

  1. Create a new V2 session using a model that fails its initial request, for example with provider_model_unavailable.
  2. Submit another user message before switching to a working model or otherwise recovering execution.
  3. Allow a later model step to complete successfully.
  4. Observe that the session retains its generated default New session - ... title indefinitely.

No user prompt content or identifying session metadata is included in this report.

Root cause

  • packages/core/src/session/runner/llm.ts: startTitleOnce(sessionID) runs only after yield* runStep(...) succeeds. A failed initial step exits before title generation starts.
  • packages/core/src/session/history.ts: firstUserMessageIfOnly returns undefined once a second user message exists.
  • packages/core/src/session/title.ts: the missing first message causes a silent return.
  • The runner records that title generation started once invoked, so there is no later recovery attempt. Durable history also means the sole-user-message condition can never become true again.

Expected behavior

A recoverable initial model failure should not permanently prevent automatic session naming. After execution recovers, the session should receive a title based on its first user message if it still has the generated default title.

Suggested fix

Allow title generation to read the first user message even when later user messages exist, while guarding the rename on the session still having its generated default title. This preserves explicit user renames while closing the failed-first-step gap.

Add a regression test covering: failed initial step, second admitted user message, successful later step, automatic rename.

Activity

  1. added
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Jul 29, 2026
  2. opencode-agent commented on Jul 31, 2026

    @opencode-agent
    Contributor

    Addressed by #39748. Automatic title attempts now coalesce only while in flight rather than latching permanently, later successful executions can retry after an initial failure, and title generation reads the first user message even after later prompts arrive. Durable checks and a sequence-guarded rename ensure explicit/manual titles win, including races during generation. Focused runner and title regressions cover failure followed by recovery. Closing as resolved on the v2 branch.

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

Metadata

Metadata

Assignees

Labels

2.0bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions