Repository navigation
fix(tier3): preserve Unicode content in JSONL agent logs - #729
Conversation
Signed-off-by: Afloat <ShuffleMonkey@163.com>
chrisknvidia
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Merge current main while retaining this change and the published release notes. Signed-off-by: Afloat <ShuffleMonkey@163.com>
|
Addressed in 72d146f: the JSONL entry is now under |
Signed-off-by: Afloat <ShuffleMonkey@163.com>
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>
|
@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>
|
Resolved the merge conflict in 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 |
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
left a comment
There was a problem hiding this comment.
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.
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 mainf7c174ea460a0ff1493f78b2af3a4430f9bdef90. 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-ranpython -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 passedpython -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, andpython -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.make lintequivalent:python -m ruff check src testsmake testdid not complete successfully in this environment (see below)make buildequivalent:python -m build(wheel and sdist)The unchanged base
8fe9723, tested withpython -m pytest -x -q, stops after 456 passed and 19 deselected attests/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 invokesmktemp -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
CHANGELOG.md