Repository navigation
feat(gateway): wakeups — checks an agent schedules for itself, and notify_agent - #351
Open
sarah-chitty-1 wants to merge 6 commits into
Open
sarah-chitty-1 wants to merge 6 commits into
sarah-chitty-1 wants to merge 6 commits into
Conversation
…tify_agent
What wakes an agent between its turns, on the env's virtual clock (urn:agentenv:wakeups/v1):
- schedule_check / list_scheduled_checks / cancel_scheduled_check: gateway built-in tools, next to get_time,
that exist only once a task turns them on (configure_wakeups step, or POST /wakeups/config). A check takes
`at` (RFC 3339 or a duration from now) and/or `every` with `until`; max_active and min_interval cap them.
- notify_agent: a trigger action that queues a notification ({channel, text}, text templated from the provoking
call) at the current virtual time. Only task designers write it; the agent has no general alert tool.
- GET /wakeups/state says when the next check is due and what is pending; POST /wakeups/take hands out each due
check and notification once (a repeating check passed several times in one jump comes out once, with a count).
Nothing here wakes anyone: a post-turn hook reads state, moves the clock and takes what is due. Opt-in throughout:
without configure_wakeups no tool appears, and a gateway without notify_agent is refused by register_env_triggers
before any request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on times, wait for discovery - take counts how often a repeating check came due and its next time directly, so a long jump over a short every costs nothing, and works the whole batch out before marking anything handed out - schedule refuses an every (or at) too long to count forward, which would otherwise break every later take - notifications are due by their parsed time, not their text (fractional seconds sorted wrong) - /wakeups/config finishes tool discovery before its name check (503 if discovery fails), so a later discovery can't replace schedule_check unseen - configure_wakeups logs a one-line completion, not the request body Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tools and config take The state, list_scheduled_checks and the too-short error showed Python's timedelta text (3:00:00), which /wakeups/config then refused when sent back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rahchitty/agent-wakeups # Conflicts: # src/agent_env/task/episode/rules.py
…history is bounded - configure with scheduled_checks false cancels the active checks, since the agent no longer has the tool to - delivered notifications are dropped, and state keeps only the last 50 finished or cancelled checks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rahchitty/agent-wakeups # Conflicts: # src/agent_env/env/gateway/constants.py
This branch has not been deployed
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 and why
In a multi-day task the agent needs a realistic way to come back later. Today it only hears from the world when the user sim writes, or when a hook wakes it for every world event. Real assistants don't work like that: they set their own reminders, and they get pushed only through real channels (a saved-search alert, a text).
This adds the gateway side of that, opt-in per task:
urn:agentenv:wakeups/v1(env/gateway/wakeups.py): once a task turns it on, the agent gets three gateway tools:schedule_check(note, at | every, until),list_scheduled_checksandcancel_scheduled_check. They run on the env's virtual clock. Caps: at most 10 active checks, and repeats no shorter than 1 hour; both are configurable.notify_agenttrigger action: a designer-declared notification on a named channel ({"type": "notify_agent", "channel": "Curbfinch alert", "text": "..."}). It's queued for the agent, not sent as the user. Only the text length is logged./wakeups/config|state|take|clear. A harness or post-turn hook reads what's due throughtake.stateexposesnext_check_at, so a runner can jump the clock to it.configure_wakeupstask step: turns the wakeups on for one env. It goes aftersync_env_clockand beforeprompt_agent.register_env_triggersrefusesnotify_agenton a gateway that lacks the feature.Nothing changes for tasks that don't use it. The tools exist only after
configure_wakeups. The extension is added last on the card, and the new trigger action is opt-in./wakeups/configreturns 409 if a backing server already serves a tool with one of these names.The design and the decisions behind it are in Linear FD-4433. The post-turn hook that wakes the agent is in a follow-up PR stacked on #265.
How it was tested
PYTHONPATH=src:packages/agentenv-protocol/src python -m pytest tst/unit/env/gateway/wakeups_test.py tst/unit/task_step/test_configure_wakeups.py tst/unit/task_step/test_register_env_triggers.py tst/unit/env/gateway/gateway_card_test.py: 118 passed.test_agent_wakeups_hook_local.py).schedule_checksensibly. They scheduled every 3–24 h, never ran away, and never mistook a labelled notification for the person.@earakely-scale
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues remain.Summary
Adds opt-in scheduled checks and trigger notifications on the gateway’s virtual clock.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR Task[configure_wakeups] --> Config[Enable check tools] Agent[Agent] --> Schedule[schedule_check] Config --> Schedule Schedule --> Queue[Wakeups] Trigger[notify_agent trigger] --> Queue Clock[Virtual clock] --> Queue Queue --> State[wakeups/state] Queue --> Take[wakeups/take] State --> Runner[Runner or hook] Runner --> Take Take --> Message[Due checks and notifications]Reviews (6) · Last reviewed commit: "Merge branch 'main' of github.com:scalea..." · Reviewed by Greptile