Skip to content

fix(always_on): the user's response time holds the agent's messages, not her answer (FD-7185) - #1011

Merged
sarah-chitty-1 merged 2 commits into
mainfrom
sarahchitty/fd-7185-always-on-a-held-user-sim-reply-arrives
Dec 5, 2026
Merged

sarah-chitty-1 merged 2 commits into
mainfrom
sarahchitty/fd-7185-always-on-a-held-user-sim-reply-arrives

Conversation

@sarah-chitty-1

@sarah-chitty-1 sarah-chitty-1 commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes FD-7185: in always_on runs, a user-sim answer held for the user's response time arrived after the agent's newer message and read as an answer to it.

The bug

The user sim read the agent's message at once, and agent-env held its answer for her response time (60 min at work in the concert task). A message the agent sent in that hour was read only when the held answer went out. So the old answer reached the agent after the newer message, stamped with the delivery time, and nothing said which message it answered.

In psi-ts-gatelark-new-country-act (v13 and v14, Gemini and Opus): at 10:05 the sim wrote "yes, buy them" for $124.66 seats, held to 11:05. At 10:27 the seats had sold out and the agent offered VIP at $480.83. At 11:05 the stale "yes" arrived and the agent bought VIP. This decided three runs.

The fix: the wait holds the agent's messages, not her answer

  • Her first look is unchanged: the same time and the same mode (morning, work, free), including the rule that a look missed during an agent turn moves to the turn's end.
  • Her response time then runs from the look. When it's up, she reads everything the agent sent by then in one read, and her answer goes out at once, labelled with the time she wrote it. A second message doesn't restart her response time.
  • An answer due during an agent turn is written at its own time, after the turn, with what was sent by then. Phone alerts and her own lines are cut at the same time, and later messages wait for her next look. Its label stays exact, so messages that cross show as crossed.
  • No response time (mode "now", or no response_times): unchanged.
  • End of run:
    • An answer due by end_time reaches the agent with the final check-in, as before. That includes one due at end_time itself, and one due during a turn that ran past end_time.
    • An answer due after the run ends is her last read: written at its time and recorded as held, never delivered.
    • The last read is always one read, so it stays within its cap and the closing's budget. When the final turn sent more after her answer time, she reads it all once, from her look when the turn ended.
    • No last read after her answer ended the run (a done with no message, or the user-sim gate's on_fail: "end").

On by default for every always_on task, with no flag (agreed with Sarah).

What changes for live runs

  • The agent sends one message and waits: the agent gets the same wakes, at the same task times, with the same texts and labels, and the same pending record. Fifteen cases pin this against main (see Tests).
  • The sim writes at the delivery time, not at her look. Her read is stamped then (user_sim_read.virtual_time = deliver_at; the look is in the new looked_at field and the new user_answer_scheduled event), and she sees phone alerts and her own lines up to then. Her wording can differ from before.
  • The agent writes again during the wait: one read and one answer to everything, instead of an answer per message. So runs have fewer sim calls and fewer counted replies (max_replies).
  • The time budget's closing: an answer due when the budget closes the run is now her last read, recorded as held, rather than delivered in the closing wake. The closing's worst case (wake_reserve_seconds) has room for one read, and that is her last read, after the closing turn. Reading her answer before the closing wake too could run past the hub's job.
  • A run that ends on an error while she waits: her messages are in unread_by_user, and she has no held answer, since she hadn't written it yet. The user_answer_scheduled event records when it was due.
  • Records that move: the post_turn_hooks read_at is now the read's time (her answer time), not her look. rate_user_satisfaction's session time moves later by her response time. Nothing in agent-env or synthetic-pipelines reads read_at.
  • The last_reply_at guard is gone; it can no longer fire.

Tests

  • New tst/unit/task_step/test_always_on_held_replies.py (31 cases):
    • Same as before (15 cases): one message in different situations: work, free, night then morning, a busy block, an answer after bedtime, a long asking turn, a quiet turn spanning her answer, no response times, an alert in the same minute, her answer at end_time, a turn past end_time and her answer, her answer before and after end_time, a quiet final turn past her answer, max_wakes. Each pins every wake (time and cause), the wake and label of her answer, the pending record and the end reason. They pass on main (fb5a5a6) and here. I also diffed every text the agent got in those runs between main and this branch: identical.
    • The behaviour change (16 cases): the VIP morning; a second message not restarting her time; her read's time and what she sees; an answer due inside a turn (messages and phone cut at its time); a "no reply" inside a turn still leading to the next read; done after a wait; the user-sim gate on a waiting answer; end-of-run cases (a wrap-up before her answer time; her answer time inside the final turn, read once; the time budget's closing; max_wakes; an answer that ends the run with messages after its time, for a blank done and for the gate; a blank done at end_time with no check-in after it); an infra-error end. A shared check asserts that no delivered answer was written before she read every message sent up to its time. All 16 fail on main.
  • Existing tests that pinned the read's time at her look now pin it at her answer time, with looked_at at the look. Their delivery assertions are unchanged.
  • always_on, user-sim and satisfaction suites (tst/unit/task_step -k "always_on or user_sim or satisfaction"): 1155 passed.
  • Every test file that mentions always_on (54 files): 1626 passed.
  • Full unit suite, on the first commit: 23,069 passed, 10 failed. Nine of those also fail on main on the same Mac (sandbox exec, CLI codegen, a git credential wrapper, a disk recipe). The tenth, a socket timing test, passes when run alone. The second commit changes only always_on.py and its tests.
  • Mutation check of the new code: 21 mutants, 19 killed. The two that survive behave the same as the real code:
    • Putting back the end_time check on reading a due answer in the loop: the check-in then reads the answer itself.
    • Not cutting her own lines at the answer time: her lines go out only in wakes, and a wake never comes after a due answer, so none can be later than it. The cut is kept to match the other two.
  • An independent review found three end-of-run problems in the first commit: an answer due at end_time missed the check-in; the last read could make two reads within a one-read cap; and a second last read could follow a blank done. The second commit fixes all three, with tests.

Overlap and follow-up

#1003 (FD-7183, fixed clock mode) touches other parts of always_on.py (clock setup, per-turn reporting, finish, the judge text) and the test harness. It doesn't touch the read and hold code. Its 60 s per tool call makes agent turns longer in task time, so answers due inside a turn become common. Those are tested here. Such an answer still arrives after the turn, labelled with the earlier time, next to the turn's newer messages; only the label shows they crossed. A short note in that wake ("written before your 11:40 message") would make it plain. That's a separate change.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge; no actionable issues were found.

Summary

Moves the user sim’s response delay before its read, so messages sent during the wait receive one answer together.

  • The user answers after her response time, with the messages she has read by then.

Acknowledgments from sarah-chitty-1: answers written during agent turns may arrive beside newer messages with only their time labels showing the crossing; clearer wake text is deferred. Time-budget closings intentionally record waiting answers as held. Error endings intentionally leave waiting messages unread.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Agent sends a message] --> B[Schedule the user's look]
  B --> C[Start response time]
  C --> D[Collect messages sent during the wait]
  D --> E[Read messages up to answer time]
  E --> F[Write answer with that time label]
  F --> G{Run still accepts a wake?}
  G -->|Yes| H[Deliver answer in a wake]
  G -->|No| I[Record answer as held]
  E --> J[Keep later messages for the next look]
Loading

Reviews (1) · Last reviewed commit: "fix(always_on): an answer due by end_tim..." · Reviewed by Greptile

sarah-chitty-1 and others added 2 commits December 4, 2026 14:24
…not her answer (FD-7185)

The user sim read at her first look and its answer was held for her
response time. A message the agent sent in that hour was read only when
the held answer went out, so the old answer reached the agent after the
newer message and read as an answer to it: the concert task's "yes, buy
them" for $124.66 seats arrived after a $480.83 VIP offer, and the agent
bought VIP.

Now she looks as before (same time, same mode), her response time runs,
then she reads everything sent by then and her answer goes out at once,
labelled with the time she wrote it. An answer due during an agent turn
is written at its time with what was sent, and what her phone got, by
then; later messages wait for her next look. A single message gets its
answer at the same time, in the same wake, with the same label as
before; only the read's recorded time moves to the answer time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the last read is one read (FD-7185)

- A due answer is read in the loop whatever end_time is, and one due at end_time itself is read before the final
  check-in, so it reaches the agent with it, as a held reply due by then always did.
- The last read is a single read, within its cap and the closing's room for one.
- No last read after her answer ended the run (a done with no message, the user sim gate's "end").
- Tests: 15 single-message cases now pin every wake, the label and the pending record, the same on main and here;
  new end-of-run cases for the final turn, the time budget's closing and an answer that ends the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sarah-chitty-1
sarah-chitty-1 requested a review from a team as a code owner December 4, 2026 23:37
@sarah-chitty-1
sarah-chitty-1 merged commit 367eeea into main Dec 5, 2026
62 of 63 checks passed
@sarah-chitty-1
sarah-chitty-1 deleted the sarahchitty/fd-7185-always-on-a-held-user-sim-reply-arrives branch December 5, 2026 02:11
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.

2 participants