fix(core): generate session titles before model execution - #42067
Merged
Conversation
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
Generate a new root session's title as soon as its first admitted prompt becomes visible, instead of waiting for the first model step and its tool calls to finish.
This restores the responsive title behavior from V1 while preserving V2's durable prompt admission boundary: queued input does not trigger title generation until it is promoted.
Before / After
Before: the runner promoted the first prompt, completed the first model step and any local tool execution, then forked title generation. A tool-heavy first response could leave the fallback session title visible for minutes.
After: the runner promotes the prompt, forks title generation, and immediately continues into context loading and the main model request. The title and first model step run concurrently, and either title or model failure remains isolated from the other.
How
packages/core/src/session/runner/llm.tsstarts the existing coalesced title fiber immediately afterSessionPending.promote(...)reports newly visible input.runSteptitle trigger.Scope
This does not generate titles for merely admitted queued prompts. It does not change title model selection, title content, truncation, or retry policy.
Testing
bun run test test/session-runner.test.tsfrompackages/core: 144 passingbun typecheckfrompackages/corebun turbo typecheck --concurrency=3, 32 tasks passingFlow
sequenceDiagram participant Inbox as Durable prompt inbox participant Runner as Session runner participant Title as Title model participant Model as Main model Inbox->>Runner: Promote first eligible prompt Runner--)Title: Fork title generation Runner->>Model: Start first model step Title-->>Runner: Persist session rename Model-->>Runner: Stream response and tools