[Engine] String tool-call arguments are emitted with \uXXXX escapes (ensure_ascii=True in OutputParser._scan)
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
terminal/serve/frontend.py を開き、OutputParser._scan() を読んでください。文字列パラメータの内容を出力する4つの json.dumps 呼び出しに注目してください。近くにある _close_scan() はすでに ensure_ascii=False を渡しており、意図したパターンを示しています。この4箇所に ensure_ascii=False を追加し、文字列パラメータにキリル文字やCJKテキストを受け取るツール(例:path = "Папка")を、ストリーミングモードと非ストリーミングモードの両方で実行してください。両方のレスポンスの arguments に \uXXXX エスケープがなく、読める文字が表示され、既存のパーサーテストがすべて通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Area
[Engine] (the server and API)
Environment
- Strata: 0.2.17
- OS: Windows 10
- GPU: RTX A4000 16 GB
- RAM: 64 GB
Related
Follow-up to the second observation in #4630 (escaped Unicode in string arguments).
The newline/array fix from 0.2.8 does not cover this.
What happens
When a tool parameter is declared as "type": "string" and contains non-ASCII text (Cyrillic, CJK, emoji, etc.), the arguments field in both streaming and non-streaming responses contains escaped Unicode:
"arguments": "{\"path\":\"\\u041f\\u0430\\u043f\\u043a\\u0430\"}"
instead of the readable form:
"arguments": "{\"path\":\"Папка\"}"
Array/object parameters and ordinary assistant text are fine.
Where
terminal/serve/frontend.py, method OutputParser._scan() — the four places that emit string parameter content via json.dumps without ensure_ascii=False.
Nearby _close_scan() already does it correctly:
json.dumps(v, ensure_ascii=False)
The streamed fragments are later concatenated for non-stream responses as well, so the escapes appear in both modes.
Suggested fix
--- a/terminal/serve/frontend.py
+++ b/terminal/serve/frontend.py
@@ -2253,7 +2253,8 @@ class OutputParser:
declared = self.sdeclared.get(pname) if pname else None
v = coerce_value(inline, declared) if pname else _SKIP
if v is not _SKIP and declared == "string":
- args(("" if self.sfirst else ",") + json.dumps(pname) + ":" + json.dumps(v))
+ args(("" if self.sfirst else ",") + json.dumps(pname, ensure_ascii=False)
+ + ":" + json.dumps(v, ensure_ascii=False))
self.sfirst = False
self.sset.add(pname)
elif v is not _SKIP:
@@ -2263,7 +2264,7 @@ class OutputParser:
if pname is not None and self.sdeclared.get(pname) == "string":
self.sset.add(pname)
- args(("" if self.sfirst else ",") + json.dumps(pname) + ':"')
+ args(("" if self.sfirst else ",") + json.dumps(pname, ensure_ascii=False) + ':"')
self.sfirst = False
self.ss, self.sval_started = "str", False
else:
@@ -2291,7 +2292,7 @@ class OutputParser:
value = rest[:end]
if value.endswith("\n"):
value = value[:-1]
- args(json.dumps(value)[1:-1] + '"')
+ args(json.dumps(value, ensure_ascii=False)[1:-1] + '"')
self.sp += end + close_len(rest, end, self.scloser)
self.ss = "between"
continue
@@ -2301,7 +2302,7 @@ class OutputParser:
if safe > 0 and rest[safe - 1] == "\n": # may be the trailing newline before </parameter>
safe -= 1
if safe > 0:
- args(json.dumps(rest[:safe])[1:-1])
+ args(json.dumps(rest[:safe], ensure_ascii=False)[1:-1])
self.sp += safe
return out
I applied this locally and confirmed that string arguments with Cyrillic now appear unescaped.
How to reproduce
Any tool with a string parameter that receives non-ASCII text (e.g. path = "Папка" or "Отчёт.md").
Note
Root cause and the exact locations were identified with the help of an AI coding assistant; the fix was verified manually.
- 主要言語
- C++
- スター
- 11.6k
- フォーク
- 1k
- 平均マージ
- 18日 13時間
- マージ済み PR(30日)
- 4
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Niko1221/Strata のほかの issue
-
needs-format
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Niko1221/Strata#6475 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 6 日以内に返信
-
needs-format
難易度 2/5 半日 初心者へのやさしさ 72/100
Niko1221/Strata#6371 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 6 日以内に返信
Niko1221/Strata の issue をすべて見る
似ている issue
-
Refactor kinematic_links integration test to use EcmScope対応中かも @patelshivani2283-lab が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
eclipse-score/lifecycle#1061 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
area/build-framework kind/enhancement priority/low
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
yugabyte/yugabyte-db#38826 ·
メンテナーはふだん 1 日以内に返信