sleep_for/sleep_until: tool contract must instruct ending the turn - #474
Open
kayeungadrian-tam wants to merge 1 commit into
Open
sleep_for/sleep_until: tool contract must instruct ending the turn#474kayeungadrian-tam wants to merge 1 commit into
kayeungadrian-tam wants to merge 1 commit into
Conversation
Observed with a weaker model: the agent called sleep_for(2m) per loop cycle but kept working in the same turn — it scheduled four alarms within a minute, finished everything immediately, and its own wakes arrived stale. The tool docstring never said the one thing that makes suspension real: stop after calling. Docstrings now instruct ending the turn, and the return payload carries the same cue where weaker models actually look. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What was broken
Field-observed with a weaker model driving a monitoring loop: the agent called
sleep_for(120)once per cycle but kept working in the same turn — it scheduled four alarms within a minute, finished all cycles immediately, and then each of its own wakes arrived stale (the session's resume handler correctly recognized them as stale and did nothing, so the loop degenerated into no-op wakes).Root cause is the tool contract: the docstring says "Suspend and wake this session" but never states the one behavior that makes suspension real — stop after calling. And the
{"ok": true}return reads as an invitation to continue.Change
Docstrings for
sleep_for/sleep_untilnow say explicitly: end your turn after the call succeeds; the waiting happens while suspended; continuing defeats the wait. The return payload carries the same cue ("next": "wake scheduled — end your turn now…") since weaker models often weight tool RESULTS over tool descriptions.Prompt-only change — no behavioral code paths touched;
tests/test_self_wake.pypasses unchanged (6/6).🤖 Generated with Claude Code