# Multi-turn challenge packs

Hybrid multi_turn execution with scripted, LLM, and human user-simulator phases, operator APIs, and calibration reviews.

Source: https://www.agentclash.dev/docs/challenge-packs/multi-turn
Markdown export: https://www.agentclash.dev/md/docs/challenge-packs/multi-turn

`multi_turn` is one of the four pack `execution_mode` values (`native`, `prompt_eval`, `responses`, `multi_turn`). Hybrid `multi_turn` execution runs a conversation loop outside the native multi-step tool loop. Each case declares a `user_simulator` manifest with **scripted**, **LLM**, and **human** phases.

> Note: Human phases block until an operator submits a turn via API or CLI. The run-agent replay page shows an awaiting-human banner while the workflow waits.

## Execution flow

1. Packs with `execution_mode: multi_turn` run the conversation loop instead of the native tool loop (handled by the worker's multi-turn executor).
2. Phases emit `turn.*` events (scripted messages, LLM-simulated user, human takeover).
3. Human phases block on operator input until timeout.
4. Scoring builds a transcript from events and evaluates `recovery_behavior` plus optional `human_preference` from arena votes.

## Operator APIs

| Method | Path | Purpose |
| --- | --- | --- |
| `POST` | `/v1/workspaces/{ws}/runs/{runId}/run-agents/{runAgentId}/turns` | Submit human user message |
| `GET` | `/v1/workspaces/{ws}/runs/{runId}/run-agents/{runAgentId}/turns/status` | Poll awaiting-human state |
| `POST` | `/v1/workspaces/{ws}/calibration-reviews` | Record a human calibration score (1–5) for a sampled run |
| `GET` | `/v1/workspaces/{ws}/calibration-reviews` | List recent calibration reviews |
| `GET` | `/v1/workspaces/{ws}/arena/tasks` | List pending pairwise arena tasks |
| `POST` | `/v1/workspaces/{ws}/arena/votes` | Submit arena preference vote |

## CLI

```bash
export AGENTCLASH_WORKSPACE="<workspace-id>"

# While a run agent is executing and awaiting human input:
agentclash run turn status <runAgentId> --run <runId>
agentclash run turn submit <runAgentId> --run <runId> --message "Fine, email me when it posts."
```

### Calibration reviews and arena votes

Record a human score for a run agent turn. Use a turn index of 0 or more and a score from 1 to 5. The server keeps two decimal places of the score.

```bash
agentclash calibration create --run-agent <run-agent-id> --turn 0 --score 4.5 --rubric-key recovery --notes "The agent resumed the task."
agentclash calibration list
agentclash calibration list --json --query '.items[] | select(.run_agent_id == "<run-agent-id>")'
```

The server returns up to 100 reviews, newest first. The query selects reviews from those results. If `calibration create` exits 75, run `agentclash calibration list` before a retry, because a retry can record a second review.

List the pending arena tasks and select the left or right run agent. You can give one `--rubric-score key=value` flag for each rubric key.

```bash
agentclash arena tasks
agentclash arena vote <task-id> --winner left --rubric-score recovery=4.5
```

The server returns up to 20 pending tasks, oldest first. If the task is not in the list, give the run agent UUID of the winner with `--winner-run-agent`.

```bash
agentclash arena vote <task-id> --winner-run-agent <run-agent-id>
```

Use `--json` or `--output yaml` to read the server response. The table shows a warning if the list reaches the server limit.

## Reference pack

Publish and run `examples/challenge-packs/multi-turn-refund-recovery.yaml` for an end-to-end smoke test. The pack demonstrates scripted escalation, LLM user simulation, and a human takeover phase.

The `user_simulator` manifest on a case looks like this (lifted from the reference pack):

```yaml
user_simulator:
  schema_version: 1
  kind: hybrid
  max_turns: 12
  phases:
    - id: open
      actor: scripted
      turns:
        - message: "I need a refund for order {{order_id}} right now."
          expects:
            - key: acknowledges_refund
              kind: contains
              value: refund
    - id: pushback
      actor: scripted
      trigger: on_assistant_mismatch
      turns:
        - message: "You quoted the wrong policy. I want a full refund today."
    - id: llm_escalation
      actor: llm
      trigger: on_assistant_mismatch
      persona: "Frustrated customer who will accept a clear timeline if empathetic"
      max_turns: 3
      until:
        - "assistant_emitted:timeline"
    - id: human_takeover
      actor: human
      trigger: manual
      timeout_ms: 900000
  calibration:
    enabled: true
    sample_rate: 0.1
  post_run:
    arena:
      enabled: true
      comparison: pairwise
```

## Web UI

The run-agent replay page groups steps by `turn_index`, shows mismatch badges, and surfaces an awaiting-human banner with a submit form while the agent is executing.

## See also

- [Bundle YAML reference](https://www.agentclash.dev/md/docs/challenge-packs/bundle-yaml-reference) — `version` keys and `execution_mode` (the `multi_turn` value is documented on this page)
- [Input sets & cases](https://www.agentclash.dev/md/docs/challenge-packs/input-sets-and-cases) — case payloads (the `user_simulator` manifest is documented on this page)
- [Replay and scorecards](https://www.agentclash.dev/md/docs/concepts/replay-and-scorecards) — read turn-grouped evidence