fix: advance turn in before_message_write to prevent race condition #10
Reference in New Issue
Block a user
Delete Branch "fix/turn-advance-race-condition"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When a speaker finishes with an end symbol, the turn was only advanced in message_sent hook. By that time, the message had already been broadcast to other agents whose before_model_resolve ran with stale turn state, causing them to be blocked.
Fix
Move turn advance to before_message_write for both end-symbol and NO_REPLY cases. Use sessionTurnHandled to prevent double-advancing in message_sent.
fb2cbaa5b3to39b758f13a39b758f13atocf9be60145