[RFC]: Support multi-step tasks with simulated users

Open
#4,624 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with src/harbor/trial/trial.py, src/harbor/trial/multi_step.py, src/harbor/models/task/config.py, and src/harbor/bridges/base.py; trace how a multi-step trial runs and how bridges and user agents are resumed and closed. Then inspect the existing tests for these paths and add coverage for step transitions, timeouts, persona selection, and log archiving. The work is done when simulated users can run across steps and bridge cleanup and verification follow the proposed lifecycle.

Written by the indexing model from the issue text.

Description

Follow-up RFC for #4463 , based on main (5d8c4586).

Motivation

MultiStepTrial.__init__ currently rejects config.user_agent is not None. Task authors need simulated users inside [[steps]] tasks so each step can be graded against the live container state while keeping conversation and workspace history across steps (#4426 only stages files at checkpoints, without live per-step verification).

Proposed changes
  1. Keep the bridge alive across steps (src/harbor/trial/trial.py, src/harbor/trial/multi_step.py)

    • Remove the config.user_agent is not None guard in MultiStepTrial.__init__.
    • Add close_bridge: bool = True to Trial._run_agent_phase (MultiStepTrial._run_step_agent passes False).
    • Call BaseBridge.export_trajectory after each step into steps/<name>/agent/bridge-trajectory.json without calling teardown.
    • Close the bridge before _stop_agent_environment() on every exit path (normal finish, min_reward abort, SEPARATE last step, and _recover_outputs) so the bridge never loses container access before exporting logs or cleaning up.
  2. Carry conversation state for both agents

    • Target agent keeps its live ACP session in the bridge (no restart/resume()).
    • User agent runs user_agent.run() on step 1 and user_agent.resume() on steps 2+.
    • Update MultiStepTrial._validate_resume_support to check self.user_agent.capabilities.resume when user_agent is set and len(steps) > 1.
  3. Per-step user persona (src/harbor/models/task/config.py)

    • Add optional user_persona_path: Path | None = None to StepConfig and steps/<name>/user_persona.md convention on Task.
    • Precedence: step.user_persona_path > steps/<name>/user_persona.md > user_agent.user_persona_path > DEFAULT_USER_PERSONA.
    • On steps 2+, pass the step instruction to user_agent.resume() and only include the persona if it changed.
  4. Confirm target agent stops before verification on step timeout (src/harbor/bridges/base.py)

    • Add async def cancel_turn(self, environment: BaseEnvironment, timeout_sec: float = ...) -> bool to BaseBridge (default True; ACP sends session/cancel and waits for the turn to settle).
    • Call it on AgentTimeoutError before step verification. If it returns False, force-close the bridge / kill the target before grading and abort remaining steps so the verifier never races with a live writer.
  5. Per-step user_agent/ log archiving

    • Mirror agent_dir archiving for user_agent_dir into steps/<name>/user_agent/, preserving it across steps when step N+1 resumes.
Open questions
  1. On steps 2+, should we omit bridge_instructions and only inject changed personas, or let user_prompt_template_path govern resumed prompts too?
  2. Should StepResult add user_agent_result: AgentContext | None for per-step token/cost tracking, or keep it trial-level only?

cc @kobe0938 @alexgshaw @jackdonaldson-surge

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.