Skip to content

Read an adjudication reply whose reason spans lines, and say which batch needed the repair - #919

Merged
WaylandYang merged 2 commits into
devfrom
fix/adjudication-raw-newline
Sep 26, 2026
Merged

WaylandYang merged 2 commits into
devfrom
fix/adjudication-raw-newline

Conversation

@WaylandYang

Copy link
Copy Markdown
Contributor

问题

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。

改动

测试

  • 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-extract 89 通过
cargo test -p utopia-server adjudication 3 通过
cargo test -p utopia-server governance 1 通过
cargo clippy --workspace --all-targets -- -D warnings 干净

🤖 Generated with Claude Code

WaylandYang and others added 2 commits September 25, 2026 23:56
…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>
@WaylandYang
WaylandYang merged commit b7aa0ab into dev Sep 26, 2026
@WaylandYang
WaylandYang deleted the fix/adjudication-raw-newline branch September 26, 2026 16:24
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.

1 participant