design(server): avoid title-worker starvation while sessions are active
@jbeda is already working on this.
Since Sep 9, 2026.
- Dominant language
- Go
- Stars
- 152
- Forks
- 16
- Avg merge
- 14h 48m
- Merged PRs (30d)
- 536
Description
Problem
Automatic session-title generation uses a two-worker coordinator. Each worker currently owns the full lifecycle: claim, provider generation, and title-result persistence.
The immediate correctness fix in #1308 prevents a title snapshot save from overwriting a live chat's newer conversation by waiting until the session has no active run. That wait is safe for history, but a title result can then occupy a coordinator worker for the full duration of a later chat run.
Two long-running sessions can therefore consume both workers while they wait to persist titles. Other sessions' title work queues behind them; once the bounded queue fills, title submissions are dropped as best effort. Chat execution remains correct, but server-wide title generation throughput becomes coupled to unrelated chat duration.
Desired outcome
Design title generation so bounded provider-generation capacity is not held while waiting for an active session to become safe to update. Preserve the no-lost-update guarantee for conversation history, durable title-attempt accounting, bounded resource use, and clean shutdown/restart behavior.
Design directions to evaluate
- A durable title-only metadata record/projection separated from the conversation aggregate.
- Aggregate revision / compare-and-swap semantics with safe retry/merge for every session writer.
- A bounded, durable deferred-commit mechanism driven by session-settlement notifications.
Do not solve this by spawning an unbounded goroutine per blocked title commit; that only relocates the resource-exhaustion and restart-recovery problem.
Context
- Immediate correctness repair: #1308
- Title coordinator:
internal/adapter/server/title_coordinator.go - Terminal persistence/title submission:
internal/adapter/server/service.go(persistRun)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.