Repository navigation
feat(task_step): set_env_clock_rate starts or stops an armed env clock in place - #631
Open
andrewpark-scaleai wants to merge 3 commits into
Open
andrewpark-scaleai wants to merge 3 commits into
andrewpark-scaleai wants to merge 3 commits into
Conversation
…k in place A task could arm an env's clock only with sync_env_clock, which re-anchors it. So a task that needs the clock armed during setup started its agent late on the virtual timeline. Nothing could stop the clock after the agent's last turn, so verifiers read a world whose time triggers kept firing. set_env_clock_rate calls clock/v1 set_rate. It keeps the clock's time and its time triggers' marks. Rate 0 stops time triggers and virtual waits.
…s error When an env is deployed more than once, the step changed the first deployment's clock, which may not be the one the agent uses. It now selects the deployment through bound_deployment: env_step_id names the deploy_env step, and an ambiguous or unmatched selection fails the step before any clock write. A refused rate change reports the HTTP status and the gateway's error field, cut to 300 characters, instead of the whole response body.
Contributor
Author
|
@greptileai review The one open finding (time triggers firing after the clock stops) was withdrawn in its thread after |
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.
Why
A graded run should give the agent the virtual time its task was written for, and its verifiers should read a world that stopped when the agent stopped. Today a task can do neither:
sync_env_clockarms the clock, which re-anchors it. A task that needs the clock armed during setup, for trigger registration or warmup, has to arm it early. The agent then starts late on the virtual timeline, and nothing resets it without re-anchoring every relative time trigger.prompt_agent. Verifiers that read the env afterwards see time triggers keep firing while they read.The gateway already supports both cases.
clock/v1set_ratechanges an armed clock's rate from its current time, keepingt0, the generation and every time trigger's mark. Rate 0 stops time triggers and virtual waits. No task step called it.What
set_env_clock_rate(env_id,virtual_seconds_per_real_second,timeout_seconds). It callsset_rateand appends{step_id, env_id, virtual_seconds_per_real_second, virtual_time}tocontext.metadata["clock_configurations"]. It fails when the env isn't deployed or its clock isn't armed, and refuses a negative rate at load.sync_env_clock's docstring names the setup pattern.episode/rules.pyand colored in the explorer's pipeline view.Two patterns:
Stopping the clock does not stop work already in flight: a trigger action mid-firing finishes, and action triggers still fire on calls by the roles they watch.
Tests
tst/unit/task_step/set_env_clock_rate_test.pydrives the step against a real gatewayClock. A clock held at rate 0 through setup starts at its armed time. A stopped clock holds its time and records it. An unarmed clock and a missing env fail the step.tst/unit/env/gateway/triggers_time_test.py: a relative time trigger doesn't fire while the clock is stopped, and fires on restart at its original mark.make lint,make unit-test(14625 passed, 8 skipped).Docs: the site's task-step reference should list
set_env_clock_ratebesidesync_env_clock, with the two patterns above.

Confidence Score: 5/5
The PR appears safe to merge, with no outstanding findings.Summary
Adds
set_env_clock_rateso tasks can start or stop an armed clock without resetting its time or trigger marks.Reviews (4) · Last reviewed commit: "test(gateway): a clock stopped at rate 0..." · Reviewed by Greptile