style: tidy tool schema normalization
This commit is contained in:
@@ -242,8 +242,7 @@ function normalizeToolParameters(tool: AnyAgentTool): AnyAgentTool {
|
|||||||
// object-ish fields, force `type: "object"` so OpenAI accepts the schema.
|
// object-ish fields, force `type: "object"` so OpenAI accepts the schema.
|
||||||
if (
|
if (
|
||||||
!("type" in schema) &&
|
!("type" in schema) &&
|
||||||
(typeof schema.properties === "object" ||
|
(typeof schema.properties === "object" || Array.isArray(schema.required)) &&
|
||||||
Array.isArray(schema.required)) &&
|
|
||||||
!Array.isArray(schema.anyOf) &&
|
!Array.isArray(schema.anyOf) &&
|
||||||
!Array.isArray(schema.oneOf)
|
!Array.isArray(schema.oneOf)
|
||||||
) {
|
) {
|
||||||
@@ -311,7 +310,9 @@ function normalizeToolParameters(tool: AnyAgentTool): AnyAgentTool {
|
|||||||
// Merging properties preserves useful enums like `action` while keeping schemas portable.
|
// Merging properties preserves useful enums like `action` while keeping schemas portable.
|
||||||
parameters: cleanSchemaForGemini({
|
parameters: cleanSchemaForGemini({
|
||||||
type: "object",
|
type: "object",
|
||||||
...(typeof nextSchema.title === "string" ? { title: nextSchema.title } : {}),
|
...(typeof nextSchema.title === "string"
|
||||||
|
? { title: nextSchema.title }
|
||||||
|
: {}),
|
||||||
...(typeof nextSchema.description === "string"
|
...(typeof nextSchema.description === "string"
|
||||||
? { description: nextSchema.description }
|
? { description: nextSchema.description }
|
||||||
: {}),
|
: {}),
|
||||||
|
|||||||
Reference in New Issue
Block a user