fix(opencode): handle session title generation failures with retry#35440
fix(opencode): handle session title generation failures with retry#354401837620622 wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found several related PRs that address session title generation: Potentially Related PRs
These are related to session title generation and the underlying infrastructure (model resolution, configuration), but none appear to be direct duplicates addressing the same silent error failure issue that PR #35440 targets. |
7140b3f to
a65c89d
Compare
a65c89d to
9230382
Compare
Three fixes for ensureTitle(): 1. Fix model resolution: wrap getSmallModel/getModel in Effect.option so resolution errors don't silently defect the fiber. 2. Fix LLM stream: replace Effect.orDie with Effect.catchAll so API errors produce a warning log instead of terminating the background fiber. 3. Fix call site: replace Effect.ignore with Effect.catchCause so unexpected defects are logged instead of silently swallowed. Additionally: - Remove small:true flag so title uses the current conversation model. - Add retry path: if first LLM call produces no title, sleep 10 seconds then retry with full conversation history for better context. Fixes anomalyco#13710
9230382 to
ace8cff
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
@maintainers This PR addresses the root cause of the intermittent auto-naming failure reported in #13710. Summary of the approach: The three bugs form a chain — any of them alone would cause silent failure. The fix addresses all three at their source:
The retry path was added as a safety net: if the first attempt produces no title (regardless of the reason), wait 10 seconds for more conversation context, verify the title is still the default, and try again with the full history. This is more robust than patching individual error causes because it handles:
|
Issue for this PR
Closes #13710
Type of change
What does this PR do?
Session auto-naming (
ensureTitle()inpackages/opencode/src/session/prompt.ts) fails silently, leaving sessions with the default"New session - ..."title.Root cause — three chained issues:
Effect.orDieon the LLM stream — any API error during title generation kills the background fiber with no recovery.getSmallModel()orgetModel()exceptions propagate as unhandled defects, silently killing the fiber.Effect.ignoreat the call site — even surviving errors are silently discarded with zero logging.Fixes:
Effect.orDie→Effect.catchAllwith structured warning logging on the stream.Effect.fnUntraced+Effect.option— resolution failures returnNoneand are gracefully skipped with a log entry.Effect.ignore→Effect.catchCauseat the fork site so defects are logged.Additional improvements:
small: true— title generation now uses the conversation model (was silently failing when no small model variant was configured for the provider).All eight possible failure paths now produce a structured log entry, from model resolution through LLM call to DB persistence.
How did you verify your code works?
Effect.catchAllon streams,Effect.fnUntraced+Effect.optionfor model resolution,Effect.catchCauseat fork site)Option,Cause,Stream,SessionV1imports are already present in the fileMessageV2.toModelMessagesEffect()to convertSessionV1.WithParts[]toModelMessage[]before the LLM callSession.isDefaultTitle()before and after the delay to handle user renamesChecklist