Skip to content

fix(stirrup_agent): libreoffice whitespace + reference_files double-nest - #1333

Merged
bxyu-nvidia merged 1 commit into
mainfrom
fix/stirrup-libreoffice-whitespace-and-double-refs
May 15, 2026
Merged

bxyu-nvidia merged 1 commit into
mainfrom
fix/stirrup-libreoffice-whitespace-and-double-refs

Conversation

@agronskiy

Copy link
Copy Markdown
Contributor

Summary

Two related GDPVal bugs that bias comparison-mode scoring.

1. LibreOffice preconvert silently drops files with whitespace in the filename

convert_to_pdf in resources_servers/gdpval/preconvert.py (and the sibling _convert_office_to_pdf in responses_api_agents/stirrup_agent/file_reader.py) passes str(input_path) straight to libreoffice --convert-to pdf. The GDPVal HF corpus includes filenames like Population v2.xlsx; libreoffice's batch-convert URI handling drops these on the floor (source file could not be loaded, rc=0), so every Office doc with a space in its name silently reaches the multimodal judge as a filename-only stub — same failure mode as the missing-JRE case fixed in #1268, but driven by the path instead of the runtime.

Fix: generalize the existing ns0-staging path to also stage when the name contains whitespace. Copy to a tempdir with a sanitized basename, run libreoffice there, move the resulting PDF back to the caller's expected location.

2. Persisted reference files are double-nested as reference_files/reference_files/

_download_reference_files materializes each row's reference files at input_files_dir/<file_path>, and every GDPVal row has file_path prefixed with reference_files/ (matching the HF dataset's directory layout). The persistence step in app.py then did shutil.copytree(input_files_dir, task_dir / "reference_files"), so artifacts ended up at task_dir/reference_files/reference_files/<hash>/<file> — double nested.

This is not just cosmetic: comparison.py's build_file_section lists <ref_dir>/reference_files/ with os.listdir (no recursion), so it saw only the inner reference_files/ subdir and zero actual reference files, biasing every pairwise judgment against whichever side actually had references.

Evidence: /lustre/.../ultra-v3/moonshotai/Kimi-K2.6/20260509_231553-df9e2fbb2daff866/nemo_gym.0 — every task directory has reference_files/reference_files/....

Fix: when input_files_dir already carries a top-level reference_files/ subdir (the HF GDPVal layout), merge contents straight into task_dir so the persisted layout is the expected single-level task_dir/reference_files/<hash>/<file>. Fall back to the previous wrapping behavior when the prefix isn't present (non-GDPVal datasets).

Test plan

  • pytest resources_servers/gdpval/tests/ responses_api_agents/stirrup_agent/tests/ → 127/127 pass
  • New test_stages_when_path_has_whitespace uses a Population v2.xlsx fixture, asserts the staged input has no whitespace, and verifies the PDF ends up at the original path
  • Existing ns0-normalization test updated for the unified stage→move flow
  • ruff check + ruff format --check clean
  • Validate end-to-end on a GDPVal pipeclean run via the pr-train

🤖 Generated with Claude Code

Two related GDPVal bugs that bias comparison-mode scoring.

## LibreOffice fails on filenames with whitespace

`convert_to_pdf` in `resources_servers/gdpval/preconvert.py` (and the
sibling `_convert_office_to_pdf` in
`responses_api_agents/stirrup_agent/file_reader.py`) passed
`str(input_path)` straight to `libreoffice --convert-to pdf`. The GDPVal
HF corpus includes filenames like `Population v2.xlsx`; libreoffice's
batch-convert URI handling drops these on the floor (`source file could
not be loaded`, rc=0), so every Office doc with a space in its name
silently reaches the multimodal judge as a filename-only stub.

Fix: extend the existing ns0-staging path to also stage when the name
contains whitespace — copy to a tempdir with a sanitized basename, run
libreoffice there, move the resulting PDF back to the original location.

## Double `reference_files/reference_files/` nesting

`_download_reference_files` materializes each row's reference files at
`input_files_dir/<file_path>`, and every GDPVal row has `file_path`
prefixed with `reference_files/` (matching the HF dataset layout). The
persistence step then did
`shutil.copytree(input_files_dir, task_dir / "reference_files")`, so
artifacts ended up at
`task_dir/reference_files/reference_files/<hash>/<file>` — double
nested.

This wasn't just cosmetic: `comparison.py`'s `build_file_section` reads
`<ref_dir>/reference_files/` with `os.listdir` (no recursion), so it
saw only the inner `reference_files/` subdir and **zero actual
reference files**, biasing every pairwise judgment against whichever
side actually had references.

Fix: when `input_files_dir` already carries a top-level
`reference_files/` subdir, merge contents straight into `task_dir` so
the persisted layout is `task_dir/reference_files/<hash>/<file>`. Fall
back to the previous wrapping behavior when the prefix isn't present
(non-GDPVal datasets).

## Test plan
- [x] `pytest resources_servers/gdpval/tests/ responses_api_agents/stirrup_agent/tests/` → 127/127 pass
- [x] New `test_stages_when_path_has_whitespace` reproduces the
  `Population v2.xlsx` failure mode and asserts the staged input has
  no whitespace + the PDF lands at the original path
- [x] `ruff check` + `ruff format --check` clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Alex Gronskiy <[email protected]>
@bxyu-nvidia
bxyu-nvidia merged commit 60d3d18 into main May 15, 2026
19 checks passed
@bxyu-nvidia
bxyu-nvidia deleted the fix/stirrup-libreoffice-whitespace-and-double-refs branch May 15, 2026 15:49

This branch was previously deployed

1 inactive deployment
public — 94285178 Deployed May 15, 2026 by copy-pr-bot[bot] via release / finalize / notify #125
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