Skip to content

Add examples/swe-agent: GLM-4.7-Flash agentic training with Harbor - #1741

Merged
Shi-Dong merged 15 commits into
mainfrom
shi/260721-promote-swe-agent-v2
Jul 28, 2026
Merged

Add examples/swe-agent: GLM-4.7-Flash agentic training with Harbor#1741
Shi-Dong merged 15 commits into
mainfrom
shi/260721-promote-swe-agent-v2

Conversation

@Shi-Dong

@Shi-Dong Shi-Dong commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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 under examples/experimental/: swe-agent-v2, swe-agent-v2-amd, and openenv. The only Harbor reference outside experimental/ is examples/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.md and docs/user-guide/rollout-endpoints.md both 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 in experimental/, 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, not swe-agent-v2. The v2 suffix only made sense inside experimental/, where it separated this Harbor-based generation from the older Nemo-Gym-based experimental/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

File Purpose
run.py Synchronous GLM-4.7-Flash launcher (the validated recipe).
run-glm47-flash-agentic-async.py Disaggregated fully asynchronous launcher.
swe_agent_function.py Sends each rollout to the Harbor agent server; implements the abort hook.
generate.py Builds rewards, metrics, and training samples.
download_and_process_data.py Converts supported datasets to Miles JSONL.
README.md End-to-end recipe: agent server, data prep, launch, verification.

It points at the public harbor-framework/harbor branch harbor-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-router flag 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.py defaults 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> and rollout_data/<step>.pt dumps 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-timeout must be generous.

Follow-up

Deleting the now-duplicated examples/experimental/swe-agent-v2 and repointing the two docs pages at examples/swe-agent will come as a separate PR, so this one stays reviewable as an addition.

Test plan

  • Long-running GLM-4.7-Flash Terminal-Bench 2 training run on these files (124+ GRPO steps, one node, 8xH200)
  • python -m py_compile on all launchers
  • ruff check examples/swe-agent/
  • git diff --check
  • Net diff against main confirmed additive-only (no deletions, no modifications to existing files other than the examples/README.md index entry)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/swe-agent/run.py
Shi-Dong added 5 commits July 21, 2026 05:35
…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.
@Shi-Dong Shi-Dong changed the title Promote SWE-Agent V2 example Add examples/swe-agent-v2: GLM-4.7-Flash agentic training with Harbor Jul 28, 2026
The synchronous launcher already omitted it; without the flag Miles
falls through to sgl-router, which is the supported path.
Comment thread examples/swe-agent-v2/run.py Outdated
Shi-Dong added 5 commits July 28, 2026 11:18
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.
@Shi-Dong Shi-Dong changed the title Add examples/swe-agent-v2: GLM-4.7-Flash agentic training with Harbor Add examples/swe-agent: GLM-4.7-Flash agentic training with Harbor Jul 28, 2026

@guapisolo guapisolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve to unblock

@Shi-Dong
Shi-Dong merged commit 32cf119 into main Jul 28, 2026
40 checks passed
@Shi-Dong
Shi-Dong deleted the shi/260721-promote-swe-agent-v2 branch July 28, 2026 20:42
Shi-Dong added a commit that referenced this pull request Jul 28, 2026
…-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.
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.

2 participants