Skip to content

docs(prompt): document Json::number vs Json(x) for non-finite doubles - #1197

Open
bobzhang wants to merge 1 commit into
mainfrom
refactor/json-number-guidance
Open

docs(prompt): document Json::number vs Json(x) for non-finite doubles#1197
bobzhang wants to merge 1 commit into
mainfrom
refactor/json-number-guidance

Conversation

@bobzhang

@bobzhang bobzhang commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Document the Json::number(x) vs Json(x) distinction for non-finite
doubles in the built-in prompt's JSON guidance.

Json(x) for a Double routes through Double::to_json, which encodes
NaN/Infinity as the strings "NaN"/"Infinity" instead of numeric
tokens, so call sites with unguarded Doubles must keep Json::number.
The guidance now records that exception explicitly; the generated prompt
(prompt/generated_default_prompt.mbt) is regenerated from
prompt/default_prompt.mbt.md by the md_to_mbt_string dev rule.

The OPENSEEK_ENGINE / OPENSEEK_ENGINE_MODE removal that previously rode
along on this branch is now its own PR: #1209.

Generated with SeekMoon

A moongrep scan of the Json::$_($_) pattern finds only Json::number(x) calls on unguarded Doubles in the current tree (plus Json::stringify, which is not a constructor). Json(x) for a Double routes through Double::to_json, which encodes NaN/Infinity as the strings "NaN"/"Infinity" instead of numeric tokens, so those call sites must keep Json::number. Record the caveat in the prompt guidance so the exception is explicit; the generated prompt is regenerated by the md_to_mbt_string dev rule.

Co-Authored-By: SeekMoon <noreply@moonbitlang.cn>
@bobzhang
bobzhang force-pushed the refactor/json-number-guidance branch from 857a881 to 01b283b Compare September 2, 2026 05:10
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