Skip to content

Fix _autonomous_active set before lock acquired, blocking user tool c…#33

Open
subindevs wants to merge 2 commits into
gently-project:developmentfrom
subindevs:fix/autonomous-active-lock-race
Open

Fix _autonomous_active set before lock acquired, blocking user tool c…#33
subindevs wants to merge 2 commits into
gently-project:developmentfrom
subindevs:fix/autonomous-active-lock-race

Conversation

@subindevs

Copy link
Copy Markdown
Collaborator

_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.

subindevs and others added 2 commits June 1, 2026 08:53
…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>
@pskeshu

pskeshu commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

does this PR study the context of run_wake_turn and _autonomous_active?

@subindevs

Copy link
Copy Markdown
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.

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