Repository navigation
Read an adjudication reply whose reason spans lines, and say which batch needed the repair - #919
Merged
Merged
Conversation
…tch needed the repair
gemini-3.5-flash through an OpenAI-compatible gateway writes a raw newline inside a
quoted reason. serde refuses it ("control character (\u0000-\u001F) found while
parsing a string"), the adjudicate_entities job retries three times on the same
reply, and the whole batch is marked failed; on a 100-document Re-DocRED base 2903
resolution_reviews stayed pending.
utopia-extract: parse_adjudication_repairing tries serde first; on failure it
escapes bare control characters inside string literals (\n, \r, \t, \u00XX) and
parses again, returning whether the repair was needed. parse_adjudication keeps
its signature and output. Newlines between tokens are untouched; \" does not end
a string; already-escaped sequences stay as they are.
utopia-server: adjudication.rs and governance.rs use the repairing parser and log
a WARN with the kb (and run) id, the batch size and the first pair's names when
the fallback was taken, the way #894/#895 report a reshaped alignment reply.
Tests: a well-formed reply is not repaired and reads the same as before; a reply
with a raw newline and a raw tab inside "reason"/"why" strings parses with the
newline kept in the reason; the escaper only touches control characters inside
strings.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Wayland Yang <wayland0916@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
gemini-3.5-flash 经 OpenAI 兼容网关裁决时,会在引号里的理由中间直接换行。JSON 不许字符串里出现裸控制字符,
parse_adjudication报Failed to parse adjudication JSON: control character (\u0000-\u001F) found while parsing a string at line 7 column 0;adjudicate_entities按退避重试三次拿到同样的回复,整批标失败。Re-DocRED 一百篇的库上 2903 条 resolution_reviews 一直 pending。改动
utopia-extract:新增parse_adjudication_repairing——先按原样 serde;解不开就把字符串字面量里的控制字符转义成\n、\r、\t、\u00XX再解一次,另回一个「修补过没有」。引号外的换行是合法空白不动;\"不结束字符串;已转义的\\n不动。parse_adjudication签名与输出不变,只是改为委托给它:形状好的回复走第一条路,产出与从前一字不差。utopia-server::adjudication/governance:两处调用改用修补版;用到了兜底就记一条 WARN,带 kb_id(治理那边还有 run_id)、这一批的对数、第一对的两个名字——同 Read the kind-word binding reply in the shapes the model actually writes so a whole base no longer stays untyped in silence #894/Read a phrase reply in whatever shape the model wrote it, and ask again a bounded number of times #895 报告对齐回复变形的做法。测试
lib.rs:a_well_formed_reply_is_not_repaired(不算修补,与parse_adjudication产出一致);a_raw_newline_inside_a_reason_string_is_repaired("reason"与"why"里各带裸换行、一个裸 tab,整批读出,换行留在理由里,标记修补过);only_control_characters_inside_strings_are_escaped(引号外的换行、\"、已转义的序列都不动)。在迁移好的本地库(
127.0.0.1:1517,utopia_adj,vector 扩展)上跑:cargo test -p utopia-extractcargo test -p utopia-server adjudicationcargo test -p utopia-server governancecargo clippy --workspace --all-targets -- -D warnings🤖 Generated with Claude Code