Formats a tool call's arguments or result for display.
Two things make a raw payload unreadable as one JSON block:
Double encoding. Our write tools accept a definition as a JSON or YAML
string, so a model often sends {"definition": "{\"nodes\": []}"}.
Pretty-printing that verbatim shows \" escapes instead of structure.
Multi-line strings. A YAML definition or an export_config result is
a string full of \n, which JSON escapes onto one line.
So: unwrap strings that are themselves JSON, and lift multi-line strings out
into their own blocks. The transformation is display-only — what was sent is
unchanged.
Formats a tool call's arguments or result for display.
Two things make a raw payload unreadable as one JSON block:
{"definition": "{\"nodes\": []}"}. Pretty-printing that verbatim shows\"escapes instead of structure.export_configresult is a string full of\n, which JSON escapes onto one line.So: unwrap strings that are themselves JSON, and lift multi-line strings out into their own blocks. The transformation is display-only — what was sent is unchanged.