Repository navigation
feat(task_step): set_env_clock_rate starts or stops an armed env clock in place - #631
Merged
Merged
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 |
andrewpark-scaleai
enabled auto-merge (squash)
November 13, 2026 01:34
cikowski
reviewed
Nov 13, 2026
cikowski
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, the step is small and the clock semantics look right. A few things before merge:
set_rate(0)goes through_change_clock, which callsclock_advanced(). That fires every trigger whose mark has already passed and returns the ids instate["due"]; their actions run after the step returns. So a verifier deployed right after the stop can still see the world change. Could the step recorddueand wait, bounded, for/triggers/stateto settle?prompt_agent._fetch_settled_trigger_statealready does that wait and could be shared.- The load check accepts NaN, inf and rates above 86400 (
rate < 0is False for NaN), so the stop pattern fails only after the solver run. Could it reuseclock._parse_rate, with tests for nan, inf and 86401? - A gateway image older than the
set_ratechange raisesEnvCapabilityUnsupported. Please give it a clear "redeploy the gateway" error and state the minimum gateway version. - The step tests drive
Clockdirectly. One integration test through the real gateway route would cover the wiring: arm, register a relative trigger, stop with the step, pass the mark, assert no fire, restart, assert it fires at the original mark. - Smaller: expose
wait_followers_sso a stop also waits for clock followers; give theclock_configurationsentry akind(virtual_timemeans configured time insync_env_clockand observed time here);sync_env_clocktakes the first deployment while this step usesbound_deployment; the docs entry mentioned in the description isn't in the PR.
This adds the primitive only: the tasks still have to adopt it, and rate 0 doesn't stop in-flight trigger actions, action triggers on watched roles, or a solver still calling tools. Worth saying in the description so nobody reads it as closing those.
earakely-scale
approved these changes
Nov 13, 2026
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