Skip to content

fix(session): preserve logical thread continuity#393

Merged
marcusrbrown merged 3 commits intomainfrom
fix/session-continuity-title-persistence
Mar 28, 2026
Merged

fix(session): preserve logical thread continuity#393
marcusrbrown merged 3 commits intomainfrom
fix/session-continuity-title-persistence

Conversation

@marcusrbrown
Copy link
Copy Markdown
Collaborator

No description provided.

@marcusrbrown marcusrbrown requested a review from fro-bot as a code owner March 28, 2026 13:23
@marcusrbrown marcusrbrown self-assigned this Mar 28, 2026
Copy link
Copy Markdown
Owner

@fro-bot fro-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR correctly implements the fix for session title persistence identified in the post-ship audit. The root cause — OpenCode auto-renaming session titles after prompts — is addressed by re-asserting the title after each prompt attempt.

Key Changes

1. New title-reassert.ts module — Best-effort session title restoration

The implementation is well-designed:

  • Null-safe early return when title is undefined
  • Try/catch wrapper with warning-level logging (failures don't abort execution)
  • Uses SDK's typed session.update endpoint

2. Integration in execution.ts — Correct placement in finally block

const result = await (async () => {
  try {
    return await sendPromptToSession(...)
  } finally {
    await reassertSessionTitle(client, sessionId, config?.sessionTitle, logger)
  }
})()

This ensures title re-assertion happens after every prompt attempt (including retries), which is the correct behavior.

3. Test coverage — Two new tests verify the behavior:

  • 're-asserts session title with SDK update payload after prompt attempts'
  • 're-asserts session title even when prompt attempt fails'

Both tests pass ✅.

Quality Assessment

Tests pass — All 1068 tests pass including the new ones
Type check clean — No TypeScript errors
Lint clean — Only warnings in unrelated test files (pre-existing)
Follows project patterns — Uses Logger injection, Result pattern would be overkill for best-effort operation
Correct layering — New module in services/session/ where storage operations belong
Documentation — Audit document clearly explains the fix

Minor Observations

  1. as Record<string, unknown> cast — The type assertion on line 17 of title-reassert.ts is acceptable given the SDK's untyped endpoint, though a more precise type could be added if the SDK exposes the shape in the future.

  2. Test mock coverage — The session.update mock is already present in createMockClient() at line 113 of the test file, which is good reuse of the test infrastructure.

Verdict

This is a targeted, correct fix for the identified root cause. The implementation is minimal, well-tested, and follows established patterns. The audit document provides excellent traceability from problem to fix.

Recommended action: Merge after CI passes.


Run Summary
Field Value
Event pull_request
Repository fro-bot/agent
Run ID 23686153603
Cache hit
Session ses_2cb6115dbffeuLRGFT6r9OoaMl

@marcusrbrown marcusrbrown merged commit 8662408 into main Mar 28, 2026
10 checks passed
@marcusrbrown marcusrbrown deleted the fix/session-continuity-title-persistence branch March 28, 2026 13:40
@fro-bot fro-bot mentioned this pull request Mar 28, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants