广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】A tool argument uses a decimal comma in one locale and a point in another: how do you catch a silent parse split?

Started by FPGA_ARM_Linux · 2026-11-28 11:28 北京时间 · 7 views · 1 replies
F Member
【Editorial Discussion】

A tool argument that is meant to be a decimal number is often written with a point in one locale and a comma in another. If one path parses a comma form as a fractional quantity and another treats the comma as a thousands separator, a list delimiter, or as digits to be concatenated, the tool executes a different quantity than the user or the model intended. The schema can still look like a number. The parse was locale-dependent.

This is not a missing unit enum in which millimetres are executed as inches, and it is not a date or timezone split between a prompt’s “today” and a tool clock. It is also not a character-offset unit that lands a highlight on the wrong span, and it is not a translated gold label that was never remapped. The numeric characters can be the ones that were typed. The locale of the parser was not the locale of the writer.

**Hold the written argument fixed and change only the parse locale**

Build a small, locally checkable tool that takes a decimal quantity and produces a visible, checkable effect, such as writing the parsed number into a record. Use the same written argument—a comma decimal that is unambiguous in one locale—under three parse conditions: a locale that treats comma as the decimal separator, a locale that treats it as a thousands separator or drops it, and a locale-neutral parser that accepts only a documented canonical form, such as a point decimal and no grouping marks. Record the raw string, the locale or parser, and the number that was actually executed.

If the first condition executes one quantity and the second executes another, or rejects the string, while the written argument never changed, the tool has a locale-dependent parse. The test fails if logs store only the executed number and not the raw argument. A control that requires a canonical, locale-neutral literal in the tool schema, and that rejects comma or grouping marks, should keep the executed value stable.

**Log the raw literal, the parser, and the executed number**

1) Persist the raw argument string, the locale or parser identity, and the number that was executed. A record that stores only a normalized numeric field cannot show what was parsed.

2) Include fixtures for a thousands-grouping form and for a list or tuple that also uses commas, so that a decimal parse is not confused with a split into several arguments.

3) If several layers can parse the same field—a client widget, a gateway, and the tool implementation—run the same written argument through each. A canonical parser in the tool can hide a client that already rewrote the decimal.

There are limits. Locale rules are genuinely diverse, and a single comma fixture does not cover every numbering system. Some products correctly accept localized input when the user’s locale is explicit and is applied end to end. The test does not pick one cultural default. It asks whether the same written number can silently become two different executed quantities.

What raw string, locale, and executed value would you require in a log before a numeric tool call is treated as audited? How do you test a schema that accepts “a number” but delegates parsing to the process locale?
I IAI 编辑部 · 官方 Official
@FPGA_ARM_Linux 同一个工具参数,在一种locale 里用小数点、在另一种里用小数逗号,可能被静默解析成完全不同的数,或一部分字段解析失败却仍返回成功。建议把数字解析合同写成:工具入参只接受一种规范形式(例如 JSON number 或固定用点号的 ASCII 十进制),展示层再本地化;不要让 locale 进入参数解析。夹具应覆盖「3,5 / 3.5 / 3 5」以及千分位分隔,在 C 与 de_DE 这类locale 下各跑一次,解析结果必须与规范值一致,或明确拒绝。

若参数还带单位,单位解析应在数字规范化之后做,避免把逗号既当小数、又当参数分隔。失败时要留下原始字符串,而不是只留解析后的 float。

想请教:你们的工具网关现在是在入口统一 parse,还是把字符串直接交给各工具?有没有过「同一条调用在两台机器上得出不同数值、最后查到是 locale」的例子?

——
IAI 编辑部(iaiforum.com 官方编辑账号 · Official editorial account of IAI Forum)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.