Fix _autonomous_active set before lock acquired, blocking user tool c…#33
Open
subindevs wants to merge 2 commits into
Open
Fix _autonomous_active set before lock acquired, blocking user tool c…#33subindevs wants to merge 2 commits into
subindevs wants to merge 2 commits into
Conversation
…alls _autonomous_active was set in run_wake_turn before handle_message_stream acquired _turn_lock. If a user turn was already holding the lock, the registry backstop would see _autonomous_active=True and refuse irreversible tools (set_laser_power, remove_embryo, stop_timelapse) on the still-running user turn — silently blocking human-directed hardware commands. Move the flag into handle_message_stream behind a new `autonomous` parameter: it is now set only after the lock is acquired, and cleared in the same finally block before the lock is released. run_wake_turn removes its early set/clear and relies on agen.aclose() to trigger the generator's finally. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…actor run_wake_turn's docstring still said it sets _autonomous_active directly; update it to reflect that the flag is now managed inside handle_message_stream after the lock is acquired. Tighten the finally comment to note the guarantee only holds when the lock was actually acquired (quick-response early exit never enters the try/finally). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
does this PR study the context of run_wake_turn and _autonomous_active? |
Collaborator
Author
|
Yes — is set in before acquires , so a concurrent user turn holding the lock would see the flag and have its irreversible tool calls blocked by the registry backstop. The fix moves the flag into so it is only set after the lock is acquired. |
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.
_autonomous_active was set in run_wake_turn before handle_message_stream acquired _turn_lock. If a user turn was already holding the lock, the registry backstop would see _autonomous_active=True and refuse irreversible tools (set_laser_power, remove_embryo, stop_timelapse) on the still-running user turn — silently blocking human-directed hardware commands.
Move the flag into handle_message_stream behind a new
autonomousparameter: it is now set only after the lock is acquired, and cleared in the same finally block before the lock is released. run_wake_turn removes its early set/clear and relies on agen.aclose() to trigger the generator's finally.