fix: retain dynamic tool schema defaults

This commit is contained in:
Tianyi Cui
2026-07-14 05:23:17 +08:00
parent f1373cd7ab
commit 863116daaf
5 changed files with 49 additions and 4 deletions
+6
View File
@@ -39,6 +39,11 @@ export interface SchemaProp {
description?: string
/** Enum of allowed values (strings only). */
enum?: string[]
/**
* Model-visible JSON Schema default annotation. Validation does not apply it;
* dynamic tool mounts may supply it even though first-party definitions do not.
*/
default?: unknown
/** Nested properties for type: 'object'. */
properties?: SchemaSpec
/** Items schema for type: 'array'. */
@@ -114,6 +119,7 @@ function propToJsonSchema(prop: SchemaProp): { schema: Record<string, unknown>;
const result: Record<string, unknown> = { type: prop.type }
if (prop.description) result.description = prop.description
if (prop.enum) result.enum = prop.enum
if (prop.default !== undefined) result.default = prop.default
const required = prop.required === true