Can the subworkflow tool input fields be optional?

Describe the problem/error/question

when in the ai tool node, it gets schema from the subworkflow.

e.g.
{
“name”:“string”,
“school”:"string
}

both query field are optional.

However, when ai input school as filter or not input anything, it shows

Received tool input did not match expected schema

Seems all field becomes mandatory. So how to make the schema field as optional input?

Thanks!

{{ $fromAI(“field1”, “Description for field1”, “string”) }}

{{ $fromAI(“field2”, “Description for field2”, “string”) }}

And clear instructions in the system prompt.

There are several ways.

Another way define in subworkflow trigger defined in json and omit the required fields :

{

“type”: “object”,

“properties”: {

"name": { "type": "string" },

"search_pattern": { "type": "string" }

},

“required”: [“name”] // “search_pattern” is optional

}

The way I’ve done it in this is to tell the AI to just add an empty string if there is no filter. Above is an example where I conditional need a metadatafilter for a vector store.

1 Like

Thanks for sharing

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.