Add examples/swe-agent: GLM-4.7-Flash agentic training with Harbor - #1741
Conversation
There was a problem hiding this comment.
Code Review
This pull request promotes the swe-agent-v2 example from the experimental directory to the main examples directory, updating all documentation and relative paths. Additionally, it refactors the launcher script run.py to introduce configurable parameters for rollout limits, save intervals, and trace directories, while updating default settings such as increasing max_seq_len to 65536. Feedback is provided regarding the removal of the --use-miles-router flag in run.py, which could unintentionally bypass the Miles Router and disrupt Token-In-Token-Out (TITO) multi-turn agentic rollouts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…e-agent-v2 # Conflicts: # docs/user-guide/agentic-chat-template.md
The example previously documented a single-step smoke test as its validated shape. Replace it with the configuration a 200-step GLM-4.7-Flash run actually used, and record the two task-pool failure modes that run exposed: synchronous step time is set by the slowest trajectory, and a pool of already-solved tasks produces no gradient. Also note that W&B can silently drop metric rows on a long run, so on-disk trace dumps are the authoritative progress signal.
Restore the stale experimental copy, the harbor-private launcher, the amd README tweak and the docs cross-references so this branch is purely additive. Removing the experimental copy and repointing the docs at the new location are a separate change.
The synchronous launcher already omitted it; without the flag Miles falls through to sgl-router, which is the supported path.
The comment pointed at speculative-decoding flags that this launcher does not set, so it read as an open instruction with nothing to act on.
The async launcher hard-coded an internal agent-server hostname as both its docstring example and its runtime default, and the README named a specific in-cluster egress service. Neither belongs in a public example, so both are now placeholders. Also points the Harbor setup at harbor-miles-v0.20.0, drops the reference to the private Harbor fork, and removes the README passages called out in review.
Both launchers defaulted --wandb-project to the project the validation run happened to use, so anyone running the example unchanged would write into it. A placeholder makes the setting obviously required.
There is no v1 under examples/ for the "v2" to distinguish this from — the only other generation lives in examples/experimental/swe-agent and is being retired. A bare version suffix at the top level just points readers at something they cannot find. Renames the directory, the two command paths in its README, the entry in the examples index, and the "V2" wording in the README title and module docstrings.
Completes the previous commit, which moved the directory but left the paths and titles inside it pointing at swe-agent-v2.
…-agent The maintained Harbor recipe was promoted to examples/swe-agent in #1741, so the three copies under examples/experimental/ are now either duplicates of it or dead code, and the docs pointed readers at a directory we no longer want them to use. experimental/swe-agent was the original Nemo-Gym-based generation (last real change 2026-03-25) and carried the repo's only two git submodules, both pointing at personal forks; removing it empties .gitmodules, so that file goes too. experimental/swe-agent-v2 is the tree that was promoted, and experimental/swe-agent-v2-amd was a near-copy of it for AMD. Every doc reference now points at examples/swe-agent.
Adds
examples/swe-agent: a GLM-4.7-Flash agentic training example that runs synchronous GRPO in Miles while a Harbor agent server creates the task sandboxes, runs the agents, and returns verifier rewards.This PR is purely additive — 7 new files, no deletions and no edits to existing examples.
Why
Miles currently has no Harbor agentic training example outside
examples/experimental/. Every Harbor-based training example lives underexamples/experimental/:swe-agent-v2,swe-agent-v2-amd, andopenenv. The only Harbor reference outsideexperimental/isexamples/eval/terminal_bench_via_agent_server, which is evaluation-only and does no training.That matters because this is the reference multi-turn agentic setup on the session-server TITO path —
docs/user-guide/agentic-chat-template.mdanddocs/user-guide/rollout-endpoints.mdboth send readers here as the worked example of a custom generate function, a custom agent function, and the abort hook. Users following those docs land inexperimental/, in a directory that also contains an unrelated GSM8K reasoning launcher and a launcher that depends on a private repository they cannot clone.Naming
The directory is
swe-agent, notswe-agent-v2. Thev2suffix only made sense insideexperimental/, where it separated this Harbor-based generation from the older Nemo-Gym-basedexperimental/swe-agent. Neither of those is being promoted, so a version suffix at the top level would point readers at a v1 that does not exist there.What is in the example
run.pyrun-glm47-flash-agentic-async.pyswe_agent_function.pygenerate.pydownload_and_process_data.pyREADME.mdIt points at the public
harbor-framework/harborbranchharbor-miles-v0.20.0, so the recipe is runnable from a clean checkout. Agent-server hostnames, checkpoint paths, and the W&B project name are placeholders rather than the values the validation run happened to use.Both launchers route rollouts through sgl-router. The deprecated
--use-miles-routerflag that the experimental copy still passes has been dropped from both, matching the configuration the validation run below actually used (use_miles_router=False,router_backend=sglang).Validation
A GLM-4.7-Flash Terminal-Bench 2 run on one node of 8xH200 has been training continuously on these files for several days and is past 124 synchronous GRPO steps, with checkpoints saved on schedule and TITO session tracking healthy throughout. The README documents that run's actual shape: 4 prompts x 8 samples = 32 trajectories per step,
--global-batch-size 32,--max-seq-len 65536,--num-rollout 200,--save-interval 20.run.pydefaults match.That run surfaced two operational lessons the README passes on in general terms. Synchronous rollout waits for the slowest trajectory in the batch, so a step that draws an unusually slow task can take several times the typical 10 minutes. And W&B can silently stop accepting some metric rows while others keep arriving, which looks exactly like a frozen reward curve — so "Verify progress" says to confirm a suspected stall against the on-disk
train_data/<step>androllout_data/<step>.ptdumps rather than a dashboard.The README also explains how to size the agent server's
--max-concurrent(one sandbox per trajectory in a step) and why--agent-timeoutmust be generous.Follow-up
Deleting the now-duplicated
examples/experimental/swe-agent-v2and repointing the two docs pages atexamples/swe-agentwill come as a separate PR, so this one stays reviewable as an addition.Test plan
python -m py_compileon all launchersruff check examples/swe-agent/git diff --checkmainconfirmed additive-only (no deletions, no modifications to existing files other than theexamples/README.mdindex entry)