Skip to content

Fix Windows subprocess decoding, reasoning-model token budget, and harbor bin resolution - #194

Merged
rng1995 merged 9 commits into
NVIDIA:mainfrom
Minervaowl7:fix/windows-and-reasoning-model-compat
Oct 27, 2026
Merged

rng1995 merged 9 commits into
NVIDIA:mainfrom
Minervaowl7:fix/windows-and-reasoning-model-compat

Conversation

@Minervaowl7

Copy link
Copy Markdown
Contributor

Fix Windows subprocess decoding, reasoning-model token budget, and harbor bin resolution

Three independent fixes found while running SkillEvaluator 0.5.0 on Windows
against an OpenAI-compatible gateway serving a reasoning model. They are
grouped because each is a small platform-compatibility correction, but they
are unrelated to each other and can be split if preferred.

  1. tool_runner: decode captured subprocess output tolerantly (all platforms)

ExternalTool.run() passed text=True to subprocess.run(), which decodes the
child's streams strictly. A child emitting bytes outside the locale codec
makes the decode fail inside subprocess's reader thread, leaving
proc.stdout / proc.stderr unset, so ToolResult.stderr becomes None and the
caller crashes on the first string operation.

Reproduced with SkillSpector on Windows, whose traceback prints a non-UTF-8
byte (0xa1) from a CJK path in the user's home directory:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 194
...
validators/security.py:358  normalized = stderr.casefold()
AttributeError: 'NoneType' object has no attribute 'casefold'

The scan itself succeeded (exit 0 with complete JSON); only the diagnostic
capture broke. Capture bytes and decode with errors="replace", and harden
_skillspector_llm_stderr_failed against a None stderr as defense in depth.

  1. rubric_eval: give reasoning models a usable completion budget (all platforms)

RUBRIC_MAX_TOKENS is 4096. A reasoning model spends that budget on hidden
reasoning before emitting any visible content, so the rubric JSON is truncated
mid-object and never parses. Measured against deepseek/deepseek-v4.1-flash:

finish_reason: length
reasoning_tokens: 4000
text_tokens: 0
content tail: 'ion is clear, specific, and explains WHEN to use the skill",\n      "pass": false'

The judge then returns its fallback ("LLM judge unavailable"), which reports as
a high-severity error even though the provider answered normally. Raise the
budget to 32768 for known reasoning families; an explicit max_tokens argument
still wins, and non-reasoning models keep 4096.

  1. harbor runner: resolve the Windows console-script suffix (Windows + docker mode)

_harbor_bin() probed only the suffix-less "harbor" name next to the active
interpreter. On Windows the console script is harbor.exe, so the probe missed
and the function fell through to shutil.which("harbor"), which also fails for a
venv-local install. The result is a false "harbor CLI not found" from
_check_prerequisites.

Scope: this only affects --env-mode docker. Native Windows local mode is
rejected earlier in _check_prerequisites by require_supported_platform(), so
the local path never reaches this code. Docker is the one Tier 3 environment
Windows supports (see docs/agents-and-sandboxes.mdx), and the readiness check
is what tells a user their install is broken before they spend on a run.

Before: doctor --env-mode docker reports "harbor CLI not found" with Harbor
0.24.0 installed. After: all four checks pass.

Tests

  • tests/utils/test_tool_runner.py: non-UTF-8 child output keeps both streams
    non-None and readable; subprocess.run is called without text=True.
  • tests/validators/test_rubric_eval.py: a reasoning model gets
    RUBRIC_REASONING_MAX_TOKENS, a standard model keeps RUBRIC_MAX_TOKENS, and an
    explicit max_tokens is preserved.
  • tests/test_harbor_local_mode.py: _harbor_bin() resolves harbor, harbor.exe and
    harbor.cmd next to the interpreter, falls back to PATH, and still returns the
    bare command name when Harbor is missing.

Verification (Windows 11, Python 3.13.13, uv-managed venv)

  • ruff check src tests: all checks passed.
  • tests/utils/test_tool_runner.py + tests/validators/test_rubric_eval.py:
    88 passed, 4 skipped. The 3 failures in the latter file are pre-existing on
    an unmodified main (44 passed / 3 failed there) and are caused by Windows
    requiring elevation for symlink creation, not by this change.
  • tests/test_harbor_local_mode.py: 19 failed / 147 passed versus 23 failed /
    138 passed on unmodified main, so this change fixes 4 tests and introduces
    none. The remaining failures are environmental (native Windows local mode is
    unsupported by design; macOS-specific runtime paths) and pre-existing.
  • End to end: skillevaluator validate on a sample skill now completes Tier 1
    (11/11) and Tier 2 (clean) with exit 0; skillevaluator doctor --env-mode
    docker reports 4/4 pass.

Not addressed: whether the reasoning-model marker list should be extended to
more model families, and whether a similar budget issue affects the Tier 3
judges, which were not exercised here.

…rbor bin resolution

Three independent fixes found while running SkillEvaluator 0.5.0 on Windows
against an OpenAI-compatible gateway serving a reasoning model. They are
grouped because each is a small platform-compatibility correction, but they
are unrelated to each other and can be split if preferred.

1. tool_runner: decode captured subprocess output tolerantly (all platforms)

ExternalTool.run() passed text=True to subprocess.run(), which decodes the
child's streams strictly. A child emitting bytes outside the locale codec
makes the decode fail inside subprocess's reader thread, leaving
proc.stdout / proc.stderr unset, so ToolResult.stderr becomes None and the
caller crashes on the first string operation.

Reproduced with SkillSpector on Windows, whose traceback prints a non-UTF-8
byte (0xa1) from a CJK path in the user's home directory:

    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 194
    ...
    validators/security.py:358  normalized = stderr.casefold()
    AttributeError: 'NoneType' object has no attribute 'casefold'

The scan itself succeeded (exit 0 with complete JSON); only the diagnostic
capture broke. Capture bytes and decode with errors="replace", and harden
_skillspector_llm_stderr_failed against a None stderr as defense in depth.

2. rubric_eval: give reasoning models a usable completion budget (all platforms)

RUBRIC_MAX_TOKENS is 4096. A reasoning model spends that budget on hidden
reasoning before emitting any visible content, so the rubric JSON is truncated
mid-object and never parses. Measured against deepseek/deepseek-v4.1-flash:

    finish_reason: length
    reasoning_tokens: 4000
    text_tokens: 0
    content tail: 'ion is clear, specific, and explains WHEN to use the skill",\n      "pass": false'

The judge then returns its fallback ("LLM judge unavailable"), which reports as
a high-severity error even though the provider answered normally. Raise the
budget to 32768 for known reasoning families; an explicit max_tokens argument
still wins, and non-reasoning models keep 4096.

3. harbor runner: resolve the Windows console-script suffix (Windows + docker mode)

_harbor_bin() probed only the suffix-less "harbor" name next to the active
interpreter. On Windows the console script is harbor.exe, so the probe missed
and the function fell through to shutil.which("harbor"), which also fails for a
venv-local install. The result is a false "harbor CLI not found" from
_check_prerequisites.

Scope: this only affects --env-mode docker. Native Windows local mode is
rejected earlier in _check_prerequisites by require_supported_platform(), so
the local path never reaches this code. Docker is the one Tier 3 environment
Windows supports (see docs/agents-and-sandboxes.mdx), and the readiness check
is what tells a user their install is broken before they spend on a run.

Before: doctor --env-mode docker reports "harbor CLI not found" with Harbor
0.24.0 installed. After: all four checks pass.

Tests

- tests/utils/test_tool_runner.py: non-UTF-8 child output keeps both streams
  non-None and readable; subprocess.run is called without text=True.
- tests/validators/test_rubric_eval.py: a reasoning model gets
  RUBRIC_REASONING_MAX_TOKENS, a standard model keeps RUBRIC_MAX_TOKENS, and an
  explicit max_tokens is preserved.
- tests/test_harbor_local_mode.py: _harbor_bin() resolves harbor, harbor.exe and
  harbor.cmd next to the interpreter, falls back to PATH, and still returns the
  bare command name when Harbor is missing.

Verification (Windows 11, Python 3.13.13, uv-managed venv)

- ruff check src tests: all checks passed.
- tests/utils/test_tool_runner.py + tests/validators/test_rubric_eval.py:
  88 passed, 4 skipped. The 3 failures in the latter file are pre-existing on
  an unmodified main (44 passed / 3 failed there) and are caused by Windows
  requiring elevation for symlink creation, not by this change.
- tests/test_harbor_local_mode.py: 19 failed / 147 passed versus 23 failed /
  138 passed on unmodified main, so this change fixes 4 tests and introduces
  none. The remaining failures are environmental (native Windows local mode is
  unsupported by design; macOS-specific runtime paths) and pre-existing.
- End to end: skillevaluator validate on a sample skill now completes Tier 1
  (11/11) and Tier 2 (clean) with exit 0; skillevaluator doctor --env-mode
  docker reports 4/4 pass.

Not addressed: whether the reasoning-model marker list should be extended to
more model families, and whether a similar budget issue affects the Tier 3
judges, which were not exercised here.

Signed-off-by: Minervaowl7 <[email protected]>

@chrisknvidia chrisknvidia 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.

Two reproducible correctness regressions remain at this head. The inline comments describe the affected configurations and narrow corrections.

Comment thread src/skillevaluator/utils/tool_runner.py Resolved

@rng1995 rng1995 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.

Automated review: 3 findings (0 P1, 1 P2, 2 P3); 2 posted inline.

Findings outside the diff or about the description:

  • CHANGELOG.md: [P3] No CHANGELOG entry for three user-facing fixes

CONTRIBUTING.md asks for a CHANGELOG.md entry when a change affects users. All three fixes do: scanner output that used to crash on undecodable bytes, a larger rubric budget for reasoning models, and Harbor resolution from the interpreter's scripts directory. The PR does not touch CHANGELOG.md.

Suggested fix: Add one ### Fixed bullet per fix under ## Unreleased.

Comment thread src/skillevaluator/constants.py Resolved
rng1995 and others added 5 commits October 13, 2026 01:32
Brings the branch up to date with main. There were no conflicts;
CHANGELOG.md merged cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
…equest

RubricJudge chose its token budget in __init__ by reading the model
keyword or resolving the environment a second time. A positional model,
an explicit endpoint (which targets the class default model), or a
provider configured after construction could therefore get a budget for
a different model than the one the request went to.

LLMClient now computes the budget when it sends each request, from the
resolved provider config. Subclasses opt in with the reasoning_max_tokens
and reasoning_model_markers class attributes, which RubricJudge sets from
the existing constants. An explicit max_tokens still always wins.

On the anthropic provider the raised budget is capped at 16384. The
Anthropic SDK refuses non-streaming requests above 21,333 output tokens
before sending them, so 32768 made the judge report itself unavailable
for every matching model behind an Anthropic-compatible base URL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
The comment above RUBRIC_REASONING_MODEL_MARKERS said that
SKILL_EVAL_LLM_MAX_TOKENS overrides the raised budget, but nothing reads
that variable. The override is an explicit max_tokens argument to
RubricJudge. Also note that the match uses the resolved model of each
request and that the anthropic provider is capped at 16384.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Capturing bytes and decoding them as UTF-8 fixed the crash on stray
bytes, but it also dropped the codec Python selects for text mode (the
locale codec, or UTF-8 in UTF-8 mode). Python scanners write in that
codec, so on a non-UTF-8 Windows locale their non-ASCII paths turned
into replacement characters, and CRLF line endings were no longer
normalized.

Go back to text=True and add errors="replace". Undecodable bytes are
still replaced instead of raising in the reader thread, while valid
output keeps its codec and universal newlines. _captured_text stays for
the timeout path and as a None guard, and the None-stderr guard in the
SkillSpector wrapper is unchanged.

The tests now run a real Python child that writes raw bytes: one with a
byte outside the codec, one with GB18030 output under a GB18030 codec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
Add one Fixed entry under Unreleased for each fix in this PR: tolerant
scanner output decoding, the reasoning-model rubric budget, and Harbor
CLI resolution from the interpreter scripts directory on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
@rng1995

rng1995 commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Review follow-up for findings outside the diff:

  • No CHANGELOG entry for three user-facing fixes: Addressed in 183ac5e. There are now three Fixed entries under Unreleased: tolerant scanner output decoding, the reasoning-model rubric budget (including the request-time model match and the Anthropic cap), and Harbor CLI resolution on Windows.

Resolve conflicts with NVIDIA#188 in inference/client.py and rubric_eval.py.
Keep NVIDIA#188's Anthropic and OpenAI request builders (reasoning effort,
structured output, per-model SDK clamp, family token limits) and feed
them this branch's per-request budget, so RubricJudge still raises the
budget for reasoning models and caps it at 16,384 on the Anthropic
provider. RubricJudge keeps both sides' class attributes.

The rubric default is now 16,384 on main, so the CHANGELOG entry and
the constants comment no longer say 4,096, and two budget tests follow
main: an explicit endpoint now uses the provider default model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@chrisknvidia chrisknvidia 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.

Re-reviewed at 45134439f6443f3d872a2159556edd0d4d911438. The resolved-model token-budget finding, selected subprocess codec finding, Anthropic non-streaming limit, incorrect override documentation, and missing changelog entries are all addressed. I found no additional PR-introduced code defect. The two original reviewer threads can now be closed as fixed.

Verification included 15 real OpenAI/Anthropic SDK requests against a local HTTP service across model/provider/override combinations, retained rubric JSON/HTML output, real subprocess output in UTF-8/CP1252/GB18030, and the actual Harbor 0.24 CLI. Selected suites recorded 540 and 589 passing tests. One timeout-stderr test failed transiently in the first run, then passed on a same-head rerun; its implementation is unchanged from main. This was not credentialed model E2E or native Windows validation, and Docker was unavailable.

Code review is clear, but the PR is not merge-ready yet: GitHub reports the branch BEHIND, CI/Security/DCO workflows at this head require approval, and the two fixed reviewer threads remain unresolved. Please update against current main and resolve the fixed threads; a maintainer needs to approve the workflows, then confirm the updated head passes the required checks.

rng1995 and others added 2 commits October 14, 2026 03:51
No conflicts; brings the branch up to date with main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
@rng1995

rng1995 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Completed review follow-up in 871df84.

  • Merged current main (c9d170e) and resolved the changelog conflict while retaining both sets of entries. GitHub now reports the PR as mergeable.
  • Reverified the resolved-target reasoning budget, explicit constructor override behavior, Anthropic cap, selected subprocess codec and universal newlines, defensive stderr handling, and Windows Harbor executable discovery. Both remaining fixed review threads now have verification replies and are resolved; all four inline review threads are resolved.
  • Clarified the token-budget wording to account for existing provider/model limits.
  • Fixed the HTML compatibility workflow's setup failure by pinning that job to ubuntu-24.04, preserving Python 3.12.11 and 3.13.5, with a regression guard. Those older patch builds are unavailable on the current Ubuntu 26.04 runner.

Validation on the updated tree, Python 3.12.13, with locked dependencies (uv sync --frozen --all-extras --python 3.12):

  • Full default suite, with the virtual environment on PATH: pytest -n 4 -q — 14,560 passed, 23 skipped.
  • make lint — passed.
  • make build — source distribution and wheel built successfully.
  • CI/HTML focused checks — 135 passed; the added runner guard was verified to fail before the workflow fix.

Earlier runs exposed an unactivated child-Python PATH and intermittent assertions in unchanged macOS timeout/Bedrock probe tests. The final full run above is green. Native Windows and credentialed model E2E were not rerun locally.

The updated head's hosted CI, Security, and DCO workflow runs have now been approved. DCO passed; CI is queued and Security is running. Hosted CI/Security results are still pending.

@rng1995 rng1995 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.

Reviewed the updated head 871df84. The review findings are addressed, all inline threads are resolved, and the merge conflict is cleared. Full local validation: 14,560 passed, 23 skipped; lint and source/wheel builds passed. Approving the code changes. Hosted CI/Security/DCO results remain pending workflow-run approval, as recorded in the follow-up comment.

@rng1995
rng1995 enabled auto-merge October 27, 2026 17:07
@rng1995
rng1995 merged commit d9fa4b4 into NVIDIA:main Oct 27, 2026
17 checks passed
@rng1995 rng1995 mentioned this pull request Oct 30, 2026
15 of 20 tasks
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
…rbor bin resolution (#194)

* Fix Windows subprocess decoding, reasoning-model token budget, and harbor bin resolution

Signed-off-by: Minervaowl7 <[email protected]>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
…rbor bin resolution (#194)

* fix(rubric): pick the reasoning budget from the resolved target per request
* docs(rubric): describe the real reasoning-budget override
* fix(tool_runner): keep the selected codec and replace undecodable bytes
* docs(changelog): add the Windows and reasoning-model fixes

Signed-off-by: Narendran Raghavan <[email protected]>
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.

3 participants