Liking cljdoc? Tell your friends :D

im.ttalk.agent.tool-args

按 JSON Schema 完整校验工具参数(designs/runtime-borrow.md §8,借 Keelson Tools/ToolArgsValidator.cs)。

模型给了枚举外的值、负数、错类型时,与其让工具函数体炸成一句看不懂的异常, 不如一次报全每处错误、带 JSON 路径、告诉模型期望什么——它多半下一轮就改对了。

认的关键字:type required properties items enum pattern minimum maximum exclusiveMinimum exclusiveMaximum minLength maxLength minItems maxItems。$ref / anyOf / oneOf / allOf / format 不深入。

宽容的地方(向后兼容,刻意):

  • integer / number 接受数字字符串(模型常给数字加引号,函数体以前也照样拿到); boolean 接受 "true"/"false";
  • 可选参数给 null 视同没给;
  • 未知键不报错。

schema 与参数的键既可以是 keyword 也可以是字符串(deftool 产 keyword、MCP 给字符串)。

按 JSON Schema 完整校验工具参数(designs/runtime-borrow.md §8,借 Keelson
`Tools/ToolArgsValidator.cs`)。

模型给了枚举外的值、负数、错类型时,与其让工具函数体炸成一句看不懂的异常,
不如**一次报全**每处错误、带 JSON 路径、告诉模型期望什么——它多半下一轮就改对了。

认的关键字:`type` `required` `properties` `items` `enum` `pattern`
`minimum` `maximum` `exclusiveMinimum` `exclusiveMaximum` `minLength` `maxLength`
`minItems` `maxItems`。`$ref` / `anyOf` / `oneOf` / `allOf` / `format` 不深入。

**宽容的地方(向后兼容,刻意)**:
- integer / number 接受数字字符串(模型常给数字加引号,函数体以前也照样拿到);
  boolean 接受 "true"/"false";
- 可选参数给 `null` 视同没给;
- 未知键不报错。

schema 与参数的键既可以是 keyword 也可以是字符串(deftool 产 keyword、MCP 给字符串)。
raw docstring

error-linesclj

(error-lines errors)

错误 → 每处一行的人话:path(描述):问题。

错误 → 每处一行的人话:`path(描述):问题`。
sourceraw docstring

format-errorsclj

(format-errors tool-name errors)

给模型看的完整报错:几处、每处的路径与问题、怎么改。

给模型看的完整报错:几处、每处的路径与问题、怎么改。
sourceraw docstring

validateclj

(validate schema args)

按 schema(JSON Schema 的 object 形状,即工具的 input_schema / parameters) 校验 args,返回全部错误 [{:path :message :description?}](无错为空向量)。

按 schema(JSON Schema 的 object 形状,即工具的 `input_schema` / `parameters`)
校验 args,返回全部错误 `[{:path :message :description?}]`(无错为空向量)。
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close