Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

- ``name`` (the agent name), ``display_name`` and ``first_name`` (else the display name's first word): how the agent's
wakes and the user sim name the user; ``agent_name``: the deployed agent always_on asks (``ask`` below).
- ``schedule`` (``wake``, ``sleep``, ``work``, ``work_days``, ``busy``): when the user reads, where ``sleep`` may be
past midnight (wake 08:00, sleep 00:30); ``response_times`` (minutes by ``morning`` / ``work`` / ``free``): how long
a reply is held; ``max_replies``: after that many replies the user stops reading. ``schedule`` and
- ``schedule`` (``wake``, ``sleep``, ``work``, ``work_days``, ``busy``): when the user first looks, where ``sleep`` may
be past midnight (wake 08:00, sleep 00:30); ``response_times`` (minutes by ``morning`` / ``work`` / ``free``): how
long after that look she reads and answers, what the agent sends meanwhile joining that read; ``max_replies``: after
that many replies the user stops reading. ``schedule`` and
``response_times`` need the task's clock (``sync_env_clock``): always_on refuses to start a run that sets either
with no clock armed. The user's time zone is the task clock's.
- ``description``, ``permissions``, ``keep_private``: in ``person``, for the reads.
Expand Down Expand Up @@ -65,10 +66,10 @@

``answer`` returns ``{"outcome": "reply" | "no_reply" | "done", "message": str, "used": str | None}``, and may add
``input``, ``raw``, ``score``, ``schema_errors``, ``turns``, ``retried``, ``first_answer``, ``shown`` and
``past_turn_cap``, which always_on records. A ``reply`` or ``done`` with text is held for the response time, then
wakes the agent as the user's message; the recorded extras (``used``, ``score``, ...) never reach the agent. A reply
that never reaches the agent (one still held when the run ends, or the answer to the last read below) is recorded with
``delivered: false``. ``done`` ends a one-sitting run after the agent's turn on that message, or at once when it has
``past_turn_cap``, which always_on records. A ``reply`` or ``done`` with text wakes the agent as the user's message at
once, labelled with the read's time (her response time ran before the read); the recorded extras (``used``,
``score``, ...) never reach the agent. A reply that never reaches the agent (the answer to the last read below) is
recorded with ``delivered: false``. ``done`` ends a one-sitting run after the agent's turn on that message, or at once when it has
no text, with no further reads; in a multi-day run it is only recorded.
When the last ``ask`` of a read returned an error, the run ends (``user_sim_error``).

Expand Down Expand Up @@ -155,8 +156,8 @@ def schedule_problems(schedule: Any, response_times: Any, max_replies: Any) -> l
if not (isinstance(busy, list) and all(isinstance(b, dict) and _local_time(b.get("start"))
and _local_time(b.get("end")) for b in busy)):
out.append('schedule.busy must be a list of {start, end} local times, like "2026-11-12T09:00"')
if response_times is not None and not schedule: # no schedule, or {}: the user reads at once, nothing is held
out.append("response_times needs a schedule (an empty one counts as none); without one, replies are never held")
if response_times is not None and not schedule: # no schedule, or {}: the user reads and answers at once
out.append("response_times needs a schedule (an empty one counts as none); without one, the user answers at once")
if response_times is not None:
if not isinstance(response_times, dict):
out.append(f"response_times must be an object of minutes by {list(RESPONSE_TIME_KEYS)}")
Expand Down
146 changes: 100 additions & 46 deletions src/agent_env/task_step/task_steps/always_on.py

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions tst/unit/task_step/test_always_on_endings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ async def test_the_user_sim_reads_the_wrap_up_and_her_reaction_and_held_reply_ar
assert tail.index("message_to_user") < tail.index("user_sim_read")
[read] = rig.events(ctx, "user_sim_read")
assert read["last_read"] is True and read["outcome"] == "reply"
assert read["virtual_time"] == "2026-11-11T14:00:00Z" and read["deliver_at"] == "2026-11-11T16:30:00Z"
# she looks at the wrap-up at 9 AM and answers once her response time is up: the answer she'd send then
assert read["looked_at"] == "2026-11-11T14:00:00Z"
assert read["virtual_time"] == "2026-11-11T16:30:00Z" and read["deliver_at"] == "2026-11-11T16:30:00Z"
held = rig.record(ctx)["pending_at_end"]["held_replies"]
assert held == {"count": 1, "items": [{"at": "2026-11-11T16:30:00Z", "text": "amazing, book La Ola too",
"done": False}]}
Expand Down Expand Up @@ -167,9 +169,10 @@ def wraps_up_late(n, texts, rig):
ctx = await rig.run(rig.step(max_wakes=1), rig.context(user=DAY))

[read] = rig.reads
assert read["time"] == "2026-11-10T12:30:00Z" # 7:30 AM, when she wakes
assert read["time"] == "2026-11-10T12:45:00Z" # she looks at 7:30 AM, when she wakes, and answers 15 min later
[event] = rig.events(ctx, "user_sim_read")
assert (event["mode"], event["deliver_at"]) == ("morning", "2026-11-10T12:45:00Z")
assert (event["mode"], event["looked_at"], event["deliver_at"]) == (
"morning", "2026-11-10T12:30:00Z", "2026-11-10T12:45:00Z")


@pytest.mark.asyncio
Expand All @@ -188,9 +191,10 @@ def runs_late(n, texts, rig):
ctx = await rig.run(rig.step(max_wakes=3), rig.context(user=DAY))

[read, *_] = rig.reads
assert read["time"] == "2026-11-10T12:30:00Z" # 7:30 AM, when she wakes, not at midnight
assert read["time"] == "2026-11-10T12:45:00Z" # she looks at 7:30 AM, when she wakes, not at midnight
[event, *_] = rig.events(ctx, "user_sim_read")
assert (event["mode"], event["deliver_at"]) == ("morning", "2026-11-10T12:45:00Z")
assert (event["mode"], event["looked_at"], event["deliver_at"]) == (
"morning", "2026-11-10T12:30:00Z", "2026-11-10T12:45:00Z")


@pytest.mark.asyncio
Expand Down
Loading
Loading