fix(session): retry failed title generation - #39748
Merged
Merged
Conversation
kitlangton
force-pushed
the
retry-session-title
branch
from
July 30, 2026 21:04
e53d5ed to
e50c342
Compare
kitlangton
force-pushed
the
optional-session-title
branch
from
July 31, 2026 00:11
70567d5 to
5f8e8b8
Compare
kitlangton
force-pushed
the
retry-session-title
branch
from
July 31, 2026 00:11
e50c342 to
018f111
Compare
kitlangton
force-pushed
the
optional-session-title
branch
from
July 31, 2026 00:44
5f8e8b8 to
8eb2231
Compare
kitlangton
force-pushed
the
retry-session-title
branch
from
July 31, 2026 00:44
018f111 to
9ffe221
Compare
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Automatic title generation now retries after a failed first execution step and still uses the session's original user prompt even when later prompts have been admitted. Explicit titles and manual renames remain authoritative.
Closes #39529.
Before / After
Before: if the first model step failed, title generation never started. After a second user message arrived, the history lookup rejected the session because it no longer had exactly one user message; a process-local latch then prevented useful recovery, leaving the fallback title indefinitely.
After: each later successful execution can start one coalesced title attempt while the session remains untitled. The attempt reads the first user message, retries after provider failure, and publishes only if the title is still absent or the exact historical fallback for that session.
A manual rename that lands during generation, including between the final read and event publication, wins: the generated rename uses the durable session event sequence as an atomic commit guard and rolls back if another session event committed first.
How
session/history.tsreturns the first user message regardless of later user-message count.session/runner/llm.tsreplaces the permanent process latch with in-flight request coalescing, clearing it after every attempt so later executions can retry.session/title.tschecks durable title state before the request and again before publication, recognizes only the exact legacy fallback derived from the session creation time, and sequence-guards the rename transaction.Scope
This PR depends on #39747 for optional title storage and display fallbacks. It does not alter title prompts, model selection, or generated title formatting.
Testing
packages/core:bun typecheckpackages/core:bun run test -- test/session-title.test.ts(8 passed)packages/core:bun run test -- test/session-runner.test.ts --test-name-pattern "retries title generation"(1 passed, 136 filtered)packages/core:bun run migration --check~/.config/opencode/plugins/voice.tsin a fixture expecting only its two invalid pluginsFlow
sequenceDiagram participant Runner participant Title as SessionTitle participant Store as Session store participant LLM participant Bus Runner->>Title: start after successful step Title->>Store: title still absent/legacy fallback? Title->>LLM: generate from first user prompt alt generation fails Title-->>Runner: finish without title Note over Runner,Title: in-flight marker clears; later execution retries else generation succeeds Title->>Bus: snapshot session sequence Title->>Store: recheck title Title->>Bus: publish rename with sequence guard Bus-->>Store: commit only if no intervening event end