Skip to content

feat(prompt_agent): resume a cut-short user-sim turn as the user - #637

Open
kaihackney-scale wants to merge 1 commit into
mainfrom
kai/usersim-resume-prompt
Open

kaihackney-scale wants to merge 1 commit into
mainfrom
kai/usersim-resume-prompt

Conversation

@kaihackney-scale

@kaihackney-scale kaihackney-scale commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

prompt_agent: resume a cut-short user-sim turn as the user, not as the agent

What

  • The Claude Code agent takes a resume_prompt (ClaudeCodeConfig). When a transient API error cuts a turn short, run_claude resumes the session with it, in place of the default _RESUME_PROMPT.
  • prompt_agent sends a user-sim USER_SIM_RESUME_PROMPT. It's negotiated against the agent's card like model and output_format, so an agent that doesn't take it is never sent it, and nothing changes for it.

Why

The default resume prompt asks the model to "continue the original request… and finish it." That's right for an agent doing a task. A user-sim's request is the agent's reply, though, so a resumed user-sim carries on as the agent. It reports work as done, says it lacks the tools to do the task, or answers the question it just asked. From then on, the conversation no longer tests the agent.

How it was tested

  • Unit tests:
    • a given resume_prompt replaces the default one on the resume;
    • the card's agent-config lists resume_prompt;
    • a user-sim whose card takes it is sent it, and one whose card doesn't is sent nothing;
    • the solver is never sent it.
  • Replay at real user-sim messages that went out of role, with the real claude CLI and each task's own system prompt, the default reply schema, tools and files. Each turn was cut at its first step and resumed, and a separate grader labeled each reply:
    • with the default resume prompt, most resumed turns came back out of role, in nearly every context;
    • with the user-sim prompt, none did;
    • on contexts where the user-sim had stayed in role, none did either.
  • E2E through this branch's run_claude: the real CLI, with the first attempt cut and reported as a timed-out API call, so the bridge's own retry logic decides to resume and does. Every run resumed with the prompt it was given. With the default prompt, nearly all resumed turns went out of role; with the user-sim prompt, none did.
  • Checks: ruff check and the plugin-API check pass. The tst/unit/task_step and tst/unit/agents suites pass, except two test_mcp_cli_builder tests that fail locally because the generated script's interpreter has no click, which is unrelated to this change.

Rollout

An agent picks this up only once its image is built from a release with this change. Until then its card doesn't list resume_prompt, so it isn't sent.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Adds a configurable prompt for retrying interrupted Claude Code turns. prompt_agent sends a user-specific prompt only to user simulators whose cards accept it.

  • Capable user simulators keep speaking as users after an API interruption.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[prompt_agent configures user simulator] --> B{Card accepts resume_prompt?}
  B -->|Yes| C[Send user-specific resume prompt]
  B -->|No| D[Keep existing config behavior]
  C --> E[Run user-sim turn]
  E --> F{Retryable API failure?}
  F -->|Yes| G[Resume session with user-specific prompt]
  F -->|No| H[Return result]
Loading

Reviews (1) · Last reviewed commit: "feat(prompt_agent): resume a cut-short u..." · Reviewed by Greptile

When a transient API error cuts a Claude Code turn short, the bridge resumes
the session with a prompt that asks the model to finish the request it was
given. A user-sim's request is the agent's reply, so a resumed user-sim
carried on as the agent.

The Claude Code agent now takes a resume_prompt, and prompt_agent sends a
user-sim one that keeps it the user, negotiated against the agent's card
like model and output_format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kaihackney-scale
kaihackney-scale requested a review from a team as a code owner November 12, 2026 16:21

This branch has not been deployed

No deployments
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.

1 participant