docs(tools): correct three comment claims about what defineTool and the subscript path do

"defineTool compiles an object root, so the annotation is a bare
TypedDict class name that opens nothing" is a false universal:
parameterSchemaSpecToJsonSchema compiles an OPEN object root, so an
empty parameter table and one with unrepresentable field names both
degrade to dict[str, Any], which opens one bracket. The conclusion the
sentence carries is unaffected -- 1 or 2 against a 182 cap -- so say
"a bare TypedDict class name or dict[str, Any], neither of which
carries a chain", in the JSDoc and the test comment that copied it.

pyScalar's docstring said the subscript tool-name comment quotes
"through the same call". It quotes through its own JSON.stringify call
site in renderToolsSdkPy and never reaches pyScalar, which only takes
const/enum scalars. Same function, different call site.

The mode-'both' test attributed assembly.tools to the public schemas().
That projection is wireSchemas, wired at ctx.systemPrompt.tools.
This commit is contained in:
Chinesezjc
2026-08-05 19:22:42 +08:00
parent 72991bbcdb
commit b44acab888
3 changed files with 9 additions and 6 deletions

View File

@@ -192,7 +192,8 @@ const MAX_CLASS_NAME_BASE = 120
* still open around it: 180 `list[` plus `Literal[` plus the paren, 182, the
* worst case. Reachable only through a raw `register()` whose `parameters`
* is array-rooted; `defineTool` compiles an object root, so the annotation
* is a bare TypedDict class name that opens nothing.
* is a bare TypedDict class name or `dict[str, Any]` — neither carries a
* chain.
*
* A CPython grammar limit, not a deployment choice, so it is fixed rather than
* configurable. The sibling `ts-types` renderer needs no counterpart: nothing
@@ -279,8 +280,9 @@ function childClassName(base: string, segment: string): string {
* parses and decodes back to the value the schema declared. DEL and the C1
* controls do reach it raw — legal but invisible, byte-for-byte as in the TS
* flavor; escaping them is a both-flavors change. The subscript tool-name
* comment quotes its name through the same call and inherits both halves,
* escapes and pass-throughs alike.
* comment quotes its name through its own call to the same `JSON.stringify`,
* never through this function, and inherits both halves — escapes and
* pass-throughs alike.
*/
function pyScalar(value: JsonSchemaScalar): string {
if (value === true) return 'True'