fix(conversation): avoid creating a conversation on chat reconnect#42
Closed
xinkuleee wants to merge 1 commit into
Closed
fix(conversation): avoid creating a conversation on chat reconnect#42xinkuleee wants to merge 1 commit into
xinkuleee wants to merge 1 commit into
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.
Summary
Reconnectpreviously calledensureConversation(get-or-create). Reconnectonly resumes an in-progress turn, so when a client reconnects to an agent
instance that has no existing conversation, creating one is both unnecessary and
a side effect — it leaves a stray empty conversation and then immediately ends
the stream because there is no ongoing turn to resume.
This changes
Reconnectto look the conversation up read-only(
conversationRepo.Get). If none exists, it sends the terminaldoneevent andreturns without creating a conversation or touching the ongoing-turn cache.
Chatstill usesensureConversation(first-turn creation is expected there).Validation
make precommit-runcd backend && go test ./...cd core && uv run pytestBackend-only change.
make precommit-runand fullgo test ./...pass. Core(
uv run pytest) and frontend suites were not run because neither is touched bythis change.
Checklist
CHANGELOG.mdunder## [Unreleased]for user-facing changes.Notes for reviewers
TestReconnectcovers the "no conversation -> don't create, senddone" path. The cache-backed resume paths (
lookupOngoingTurnID/replayCachedResponses) still require Redis and aren't unit-tested here;s.cacheis a concrete*redis.Client, so covering them would need miniredisor a cache interface — flagged as a possible follow-up.
chat.go(the fix) andchat_test.go(the test), 2 files total.