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

@@ -353,8 +353,9 @@ describe('mode-aware wire contribution', () => {
it("assembles under a python runtime in mode 'both' as well, SDK and schema together", async () => {
// `both` reaches the same wireSchemas/requireCodeRuntime/SDK-section code
// as `code`, so this pins the mode-by-language matrix rather than a
// separate path — including that `schemas()` under `both` projects the
// Python flavor instead of hitting the flavor-table guard.
// separate path — including that the `wireSchemas` projection behind
// `assembly.tools` picks the Python flavor under `both` instead of hitting
// the flavor-table guard.
const { ctx, systemPrompt } = await setup({ mode: 'both', runtime: { language: 'python' } })
registerEcho(ctx)
const assembly = await systemPrompt.assemble()

View File

@@ -577,7 +577,7 @@ describe('renderToolsSdkPy', () => {
// open around this annotation, so 180 `list[` plus the innermost bracket
// plus that paren is 182 of CPython's 200. Only a raw `register()` reaches
// it — `defineTool` compiles an object root, whose annotation is a bare
// TypedDict name that opens nothing.
// TypedDict name or `dict[str, Any]`, neither of which carries a chain.
const rooted = (depth: number): ToolSdkSchema => {
let schema: Record<string, unknown> = { type: 'string', const: 'x' }
for (let i = 0; i < depth; i++) schema = { type: 'array', items: schema }