Skip to content

fix(swe-smith): preserve parametrized test IDs when grading - #690

Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/swe-smith-parametrized-test-ids
Open

Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/swe-smith-parametrized-test-ids

Conversation

@liuzhengyang699

Copy link
Copy Markdown

Fixes #689.

A pytest node ID can contain spaces, for example test_example.py::test_pass[hello world]. The harness's \S+ match truncates that ID at the first space. Even when pytest reports the test as passed, the evaluator cannot find its full F2P/P2P ID and assigns zero reward.

Match reports against the complete escaped IDs already available in the evaluation metadata. This handles whitespace and punctuation without confusing a parameter such as a - b with pytest's failure-reason separator. The strict pass/missing-test rules and ANSI stripping are retained.

Two regressions run real pytest subprocesses through evaluate(): an all-passing parametrized suite now earns reward 1, while a suite containing a failed test still earns 0. Additional cases cover verbose and summary reports, xdist prefixes, colors, overlapping IDs, and regex punctuation. Both evaluator regressions fail on unchanged main.

Validation

  • uv run --locked --no-sync pytest -v --durations=20 tests — 269 passed, 4 skipped.
  • uv run --locked --no-sync pyright — 0 errors, 0 warnings.
  • uv run --locked --no-sync pre-commit run --all-files --show-diff-on-failure — passed.
  • uv run --locked --no-sync ruff check ., uv run --locked --no-sync ruff format --check ., and uv run --locked --no-sync python scripts/check_headers.py — passed.
  • UV_PROJECT_ENVIRONMENT=/tmp/agent-lightning-nodeids-docs uv run --locked --no-sync mkdocs build --strict, uv build --no-sources, and git diff --cached --check — passed.

This was found during a follow-up audit of the coding example with AI assistance. AI assistance was also used for the fix, tests, and review. Validation used CPU pytest cases; no SWE-smith dataset rollout or GPU training was run.

@liuzhengyang699
Zhengyang Liu (liuzhengyang699) marked this pull request as ready for review November 7, 2026 06:31
Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:31

Copilot AI 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.

🟢 Approval recommended

No active review issues are identified for the change preserving complete parametrized pytest IDs.

No open issues 🎉

What changed in this PR

Fixes #689 by preserving complete parametrized pytest IDs when grading SWE-smith tasks, preventing passing tests with spaces in their IDs from receiving zero reward.

Changes:

  • Matches pytest reports against escaped test IDs from evaluation metadata while retaining ANSI stripping and strict missing-test handling.
  • Adds real-pytest evaluator regressions and parser cases for whitespace, punctuation, overlapping IDs, and report formats.
  • Documents full-ID matching and missing-test behavior.
File Description
tests/​examples/​test_swe_smith_test_statuses.py Adds evaluator and parser regression coverage for complete test IDs.
examples/​swe_smith/​agents/​smith_agent.py Matches report statuses against known, complete evaluation IDs.
docs/​75-example-coding-agent.md Explains full-ID matching and treatment of missing tests.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

SWE-smith gives zero reward for passing parametrized tests with spaces in their IDs

2 participants