Repository navigation
feat(prompt_agent): keep the user-sim's own trajectory - #474
Open
kaihackney-scale wants to merge 5 commits into
Open
kaihackney-scale wants to merge 5 commits into
kaihackney-scale wants to merge 5 commits into
Conversation
… role, and keep its trajectory
A user-sim is sent the agent's reply as its own user turn, so a reply that already answers the sim's
next question invites the sim to answer it, and once one assistant-style message is in its resumed
session the roles can stay swapped for the rest of the conversation.
- user_message_template: the text a user-sim is sent in place of the agent's reply, with {reply}
standing for it; file parts follow as they are. Human peers are never framed.
- user_sim_guard {max_chars, reject_markdown, retry_message}: a user-sim message that fails it is
asked for again once in the same conversation; the second answer goes on either way and
usersim_guard records what failed and whether the retry passed.
- The user-sim's own trajectory, when its card serves one, is stored per answer under
<trajectory prefix>/usersim/ and recorded in usersim_trajectories (best effort).
The template and the guard are off unless set. Keeping the trajectory adds one fetch per user-sim answer
when the card offers it; a failed fetch is logged and the conversation goes on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kaihackney-scale
marked this pull request as ready for review
November 4, 2026 17:41
… empty user-sim trajectories
A list holding "{reply}" passed the placeholder check and then failed on the
first user-sim turn. A trajectory fetch that stored nothing was recorded with
url None; it is now logged and left out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop user_message_template and user_sim_guard. A length/markdown guard flags ordinary user messages on many tasks (detailed instructions, pasted emails, lists of files), and the reply framing is unproven, so neither ships until a measured design replaces them. Saving the user-sim's own trajectory per answer stays: it is what every later fix is checked with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
When a multi-turn conversation uses a user-sim, only the agent's trajectory is kept. The user-sim's own run isn't. So when a user-sim goes wrong, nobody can see what it did on that turn: what it read, what it reasoned, or which tools it called. Any fix to user-sim behavior has to be checked against exactly that.
What
When the user-sim's card serves
urn:agentenv:trajectory/v1, each of its answers' trajectories is stored under<trajectory prefix>/usersim/. Each one is recorded inmetadata.usersim_trajectorieswith:It's best effort:
Human peers and user-sims without the extension are unchanged. The only cost is one trajectory fetch per user-sim answer, and only when its card offers one.
An earlier revision of this PR also added
user_message_template(wrapping the agent's reply) anduser_sim_guard(a length/markdown retry). Both are removed:They'll come back, if at all, as part of a measured design.
Tests
tst/unit/task_step/test_prompt_agent_user_side.pycovers three cases:pytest tst/unit/task_step -k prompt_agent: 232 passed.ruff check .is clean.End to end
I ran a clone of a real multi-turn prod task with a user-sim on this branch's step code, using
agent-env task run --k 1. All 11 steps completed.metadata.usersim_trajectorieslists all three user-sim turns, each pointing under<trajectory prefix>/usersim/.The sandboxes were terminated after the run.
🤖 Generated with Claude Code


Confidence Score: 5/5
The current diff appears safe to merge.Summary
The current diff adds user-sim trajectory capture to
prompt_agent.Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'framework/..." · Reviewed by Greptile