# Agent Behavior Alignment

Matches a reference agent's behavior by comparing traces until they align.

- Repository: https://github.com/QwenLM/qwen-code (28858 stars)
- Category: AI and agents
- License: Apache-2.0
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add QwenLM/qwen-code --skill agent-reproduce-align -g -a claude-code -y`
Codex: `npx skills add QwenLM/qwen-code --skill agent-reproduce-align -g -a codex -y`
Cursor: `npx skills add QwenLM/qwen-code --skill agent-reproduce-align -g -a cursor -y`
Gemini CLI: `npx skills add QwenLM/qwen-code --skill agent-reproduce-align -g -a gemini-cli -y`

## Description

Use after a Codex or Claude Code feature has been implemented in Qwen Code to run the selected reference agent and Qwen Code under the same scenario, capture HTTP and terminal traces, compare request bodies, tool/function schemas, outputs, and iterate until the reproduced behavior is close enough.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Agent Reproduce Align

## Purpose

Use this skill when Qwen Code already has a candidate implementation and needs evidence-based parity with a selected reference agent: `codex` or `claude-code`. The goal is not byte-for-byte equality; it is matching the observable contract that matters for the feature.

Default target repo: the current working directory. Use a user-specified path only when the user explicitly provides one.

## Reference Agent Selection

Use the same reference agent selected during `$agent-reproduce-feature`. If the earlier choice is unavailable, ask once and record the answer in the scenario or run notes.

## Workflow

1. Re-state the parity target:
   - feature name and trigger
   - selected reference agent
   - one baseline prompt or interaction script
   - acceptable differences
   - must-match fields
2. Run the reference agent and Qwen Code in separate capture directories with the same scenario.
3. Capture the selected reference agent's local state before and after the
   reference run when state may affect parity.
4. Normalize traces with `scripts/normalize_trace.py`.
5. Compare normalized traces with `scripts/compare_traces.py`.
6. Inspect differences in this order:
   - reference-agent state changes that explain behavior
   - missing tool/function names
   - schema shape and required fields
   - model settings and response mode
   - prompt role/order differences that affect behavior
   - terminal-visible output and exit status
7. Patch Qwen Code, rerun the smallest failing scenario, and repeat.
8. Preserve only redacted minimal fixtures in the repo.

Read `references/alignment-workflow.md` before the first comparison pass.

## Common Commands

Normalize:

```sh
.qwen/skills/agent-reproduce-align/scripts/normalize_trace.py \
  .repro-runs/reference/http.jsonl \
  > .repro-runs/reference/normalized.json
```

Compare:

The rest: https://github.com/QwenLM/qwen-code/blob/HEAD/.qwen/skills/agent-reproduce-align/SKILL.md
