Skip to content

sleep_for/sleep_until: tool contract must instruct ending the turn - #474

Open
kayeungadrian-tam wants to merge 1 commit into
andrewyng:mainfrom
kayeungadrian-tam:fix/selfwake-end-turn
Open

sleep_for/sleep_until: tool contract must instruct ending the turn#474
kayeungadrian-tam wants to merge 1 commit into
andrewyng:mainfrom
kayeungadrian-tam:fix/selfwake-end-turn

Conversation

@kayeungadrian-tam

Copy link
Copy Markdown

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_until now 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.py passes unchanged (6/6).

🤖 Generated with Claude Code

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

1 participant