fix(swe-smith): parse pytest statuses that include ANSI color - #599
Zhiyuan He (hzy46) merged 2 commits into
Conversation
Pytest color codes glue themselves to PASSED, so the reward parser misses every passing node and scores a green suite as 0/N. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🟢 Approval recommended
The reviewed changes address the parsing issue and include regression coverage.
Pull request overview
Fixes SWE-smith pytest status parsing when ANSI color codes surround test results.
Changes:
- Strip ANSI escape sequences before parsing statuses.
- Force pytest color output off during evaluation.
- Add regression tests.
File summaries
| File | Description |
|---|---|
tests/examples/test_swe_smith_agent.py |
Tests ANSI parsing and pytest command construction. |
examples/swe_smith/agents/smith_agent.py |
Implements ANSI stripping and disables pytest colors. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@microsoft-github-policy-service agree |
|
Thank you for this contribution. Please remove the test here as we have already had a lot of tests. I am checking with our team member about this issue. If confirmed, we will merge your PR. |
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for the review. I have removed the extra tests as requested. The remaining change is only in |
Ldemon (ldemon2333)
left a comment
There was a problem hiding this comment.
accept pr for --color=no
Summary
SmithAgent grades SWE-smith rollouts by regex-matching
PASSED/FAILEDin pytest-rAoutput. When pytest emits ANSI color (a repoaddopts = --color=yes,PY_COLORS=1, or a TTY), those codes glue themselves to the status token:parse_test_statuses()never sees a barePASSED, so a fully green suite is scored0/N. This is a false negative in the reward, not a failed test.This PR:
--color=noso the evaluator does not depend on TTY or repo color settingsThis does not change SWE-bench Verified scoring, which uses the official swebench harness rather than this parser.
Validation
PYTHONPATH=. python -m pytest tests/examples/test_swe_smith_agent.py -q # 27 passed uvx ruff check examples/swe_smith/agents/smith_agent.py tests/examples/test_swe_smith_agent.py uvx ruff format --check examples/swe_smith/agents/smith_agent.py tests/examples/test_swe_smith_agent.pyReproduced locally on
cantoolsSWE-smith instances whose pytest log showed185 passedwhile the parser reportedFAIL_TO_PASS 0/60. After stripping ANSI, all 185 nodes parse asPASSED.AI assistance: Cursor Grok 4.6 helped investigate, implement, and validate this change. I reviewed the diff and ran the checks above.