Skip to content

fix(tier3): preserve Unicode content in JSONL agent logs - #729

Merged
rng1995 merged 17 commits into
NVIDIA:mainfrom
Afloat16:fix/preserve-unicode-jsonl-content
Nov 23, 2026
Merged

rng1995 merged 17 commits into
NVIDIA:mainfrom
Afloat16:fix/preserve-unicode-jsonl-content

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Agent JSONL reconstruction uses str.splitlines(), which treats Unicode NEL, LINE SEPARATOR and PARAGRAPH SEPARATOR characters as record boundaries. These characters are legal inside JSON strings. When a command, observation or response contains one literally, the resulting fragments fail JSON decoding and valid evaluation evidence is silently lost.

Split JSONL records at LF in the Claude Code, Cline, OpenCode and both Codex decoding paths. Per-record whitespace handling continues to accept CRLF. The Cursor plain-text heuristic is unchanged.

Merge and current verification (2026-11-19)

At 8f59d628b42a4e94c1d7d6a594708d4ed933d766, merged upstream main f7c174ea460a0ff1493f78b2af3a4430f9bdef90. Resolved the adjacent Claude-parser changes by preserving main's call-ID index from #733 together with this PR's five LF-only record splits. The upstream tool-result pairing tests and the original Unicode regressions are retained, as are both release notes. Reverting only the five LF-only splits and their explanatory comment restores main's converter file byte-for-byte.

On Linux with Python 3.12.14 and the frozen uv.lock, re-ran python -m pytest tests/tier3/test_jsonl_unicode_content.py tests/tier3/test_log_converters.py tests/tier3/test_claude_tool_result_pairing.py -q — 62 passed. This includes all 30 Unicode cases and the new upstream pairing regressions. Also passed python -m ruff check src tests, Ruff formatting for the affected Python files, python scripts/check_oss_boundary.py --root . --allowlist config/oss_boundary_allowlist.json, and python -m build (wheel and sdist).

Hosted CI, Security, DCO Check and Request NVSkills CI workflows for this head await maintainer approval.

Previous verification

All 30 new regressions fail on unchanged base 8fe9723. Each compares literal Unicode JSON with its escaped equivalent, covering three separators, LF/CRLF and five parsing paths, including command and tool-result content.

python -m pytest tests/tier3/test_jsonl_unicode_content.py tests/tier3/test_log_converters.py tests/test_harbor_collector_runtime_failures.py -q — 243 passed.

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes (Unreleased changelog)
  • Ran make lint equivalent: python -m ruff check src tests
  • Full make test did not complete successfully in this environment (see below)
  • Ran make build equivalent: python -m build (wheel and sdist)
  • Did not add credentials, private datasets, or proprietary benchmark content

The unchanged base 8fe9723, tested with python -m pytest -x -q, stops after 456 passed and 19 deselected at tests/ci/test_gateway_benchmark_workflows.py::test_gitlab_enriched_tier1_applies_the_keyless_job_baselines[extra0-expected0]. The sandbox has no /tmp, while that workflow fixture explicitly invokes mktemp -d /tmp/skillevaluator-enriched-tier1.XXXXXX. The same test fails for the same reason on the retry branch. No full-suite pass is claimed.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

Signed-off-by: Afloat <ShuffleMonkey@163.com>

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

Thanks, this is a real one. I reproduced it on main with a Claude stream-json log whose tool_result contains a literal U+2028: the record fails to decode and the result is lost (two of three events survive). Node's JSON.stringify writes U+2028/U+2029 literally, so this can happen in real claude-code.txt logs. The fix matches what the Gym rollout reader already does, CRLF logs still parse because each record is stripped, and the 30 new tests fail on main and pass here; the existing log converter tests still pass.

One heads-up: #733 touches the line right next to this change in the Claude parser (it adds the call-ID index above the loop), so whichever of the two lands second needs a small rebase. The CHANGELOG entry also sits next to the ones in #728 and #731, which is the usual trivial conflict.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>

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

Thanks, @Afloat16, for fixing Unicode preservation in JSONL reconstruction. Splitting records on LF preserves literal Unicode separators inside command and result strings, and CRLF records continue to parse. I found no new actionable issues on this head.

Validation: 58 focused Unicode-content and existing log-converter tests passed.

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

Not blocking, two notes for the description. With split("\n"), text handed straight to these parsers (the import-traces agent_log path) no longer treats a bare \r as a record boundary, so a CR-only JSONL string yields no steps where it used to parse; file-based loading is unaffected because read_text normalises CR, and no supported agent writes CR-only logs. Worth stating too that on main this is not just lost evidence: a Claude log whose skill-read record contains a literal U+2028 grades skill_execution as 0 instead of 1, so graded scores were wrong for such logs.

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

Thanks @Afloat16 for this contribution! I reviewed b2341422e0. I reproduced the problem on main, confirmed this change fixes it, checked that the new tests fail on main, and ran the new and related tests on this head (all pass). I left 1 inline comment (1 P3); please take a look.

Comment thread CHANGELOG.md Resolved
Merge current main while retaining this change and the published release notes.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Addressed in 72d146f: the JSONL entry is now under Unreleased / Fixed, with main's published release notes preserved. It also explicitly documents the CR-only behavior for strings passed directly to the parsers; file-based imports retain newline normalization. Preserving Unicode-bearing skill-read records also preserves the evidence used by skill_execution grading, as noted in review. This PR's existing production and regression-test changes are preserved, and git diff --check passes. Hosted workflows await maintainer approval.

Signed-off-by: Afloat <ShuffleMonkey@163.com>

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

Thanks @Afloat16 for this contribution and for addressing the earlier review! I re-checked 6f779ad6e7: all 1 earlier comment is resolved in the code, the tests pass, and I found nothing new. Approving.

Resolve the CHANGELOG.md conflict by retaining this PR's entry and the upstream independent-diagnostics entry.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Preserve the indexed Claude tool-result pairing from main together with
this branch's LF-delimited JSONL parsing and Unicode regression tests.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
Signed-off-by: Afloat <ShuffleMonkey@163.com>
@rng1995

rng1995 commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

@Afloat16 - Please resolve merge conflict to merge the PR.

Synchronize with NVIDIA/SkillEvaluator main f867b7f.
Retain this PR's entry under Unreleased and preserve published release history.

Signed-off-by: Afloat <ShuffleMonkey@163.com>
@Afloat16

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict in 017afe891b7c35c84ae5ba6eac66eae870f6ca4f by merging main f867b7f311. The PR release note remains under Unreleased, and published release history is preserved.

The implementation and regression-test patch has the same stable patch ID before and after synchronization. On the merged tree, 58 focused tests pass (Linux, Python 3.12.14); full-source Ruff, changed-file formatting and git diff --check pass. The branch is mergeable again. The new CI, security and DCO workflows await maintainer approval.

rng1995 and others added 4 commits November 20, 2026 10:09
Resolve CHANGELOG.md by keeping main's Unreleased/Fixed entries unchanged and
retaining this PR's JSONL Unicode entry in the same Unreleased list.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
… fix

State in the release note that a Claude Code log whose skill-read record held a
literal Unicode line separator previously lost that record and could score
skill_execution 0 instead of 1, as raised in review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
The CR-only note said file imports still normalize line endings, which
reads as covering import-traces export files. An export's agent_log is a
string decoded from JSON, so a CR-only value is not normalized there: it
is no longer split into records and is reported as an unsupported agent
log format. Only agent log files read from a trial directory keep
newline normalization, because they are read with Path.read_text.

Pin both sides in tests: the five parsers return None for a CR-only
string, an import-traces export (v1 wrapper and JSONL) reports the
unsupported-format warning for it while LF and CRLF logs parse, and a
CR-only claude-code, cline, opencode or codex log file in a trial
directory still loads through load_trajectory_with_fallback.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Resolve the CHANGELOG.md conflict by keeping main's entries and this change's entry under Unreleased.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>

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

Thanks @Afloat16 for this contribution! I re-checked 4687b6ace: I merged current main into the branch (the only conflict was CHANGELOG.md, resolved by keeping main's entries and this entry under Unreleased), confirmed that every earlier review comment is addressed in the code, and ran this PR's tests and ruff, which pass. I found nothing new. Approving. I also pushed two changelog/test commits: the release note now says the skill_execution scoring effect, and where CR-only logs are and are not split (a CR-only agent_log inside an import-traces export is no longer split into records, while agent log files read from a trial directory keep newline normalization), with tests pinning both sides.

@rng1995
rng1995 merged commit 55b3569 into NVIDIA:main Nov 23, 2026
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