Repository navigation
Conversation
This branch has not been deployed
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.
Fixes #509
Summary
Avoid allocating an Agent session lease when queue dispatch finds no queued message.
Root cause
After a successful turn,
run_chain()callsConversations.dispatch()even when the queue may be empty. Previously,dispatch()started a project Agent session before checking for a queued message. When no queued message existed, it returned without an executing turn ever taking ownership of that newly created session, leaving an orphanagent:session row until lease expiry.The isolated-main reproduction confirmed an extra session row after a normal completed turn with no queued follow-up. During its lifetime, that row could cause project rename, deletion, or cleanup operations to be rejected as if another window still had the project open.
Change
Move
start_agent_session()until after dispatch has identified an actual queued message, while keeping the operation inside the existing transaction and admission-lock guarantees.This avoids empty-dispatch leases and preserves the existing queue/admission behavior introduced by #381.
Tests and verification
test_assistant_dispatch_lease.py.Scope
This is a minimal Agent session lease lifecycle fix. It does not change queue ordering, turn execution semantics, or the admission-lock behavior from #381.
Related: #381, #379, #502.