Structured output parser for ai tools

hey,

I know how structured output parser works, it gets attached to an ai agent, but my question is, say I have 4-5 tools in the same AI agent like send email, create task, how can i tell each of my tools to output in a specific way like send email must output email, subject, body etc, task must have start date, end date, description, time etc, since I only have one structured output thats responsible for the whole agent but I have different fields expecting from each tools, how to acheive this?

Hi @Suhani_Bhatt

You should create subworkflows as your agent tools. Then you can have an output parser for each tool, and complete the task within the sub workflow.

I’ll make you a quick example.

@Suhani_Bhatt

Here’s a workflow that uses two sub agents to output different json formats and complete their job before going back to the main tool.

:heart:If this response helped you, please click the heart to show that it is useful
:white_check_mark:If this response solved your issue, mark it as the solution to help the community

Thanks for this tip, looks perfect, my question is will this approach be moer expensive as far as tokens are concerned?

@Suhani_Bhatt

It will probably not be more expensive. Your agent that did everything all together was most likely running multiple times in a decision making process.

Determining what the need was, then sending something to a tool.

With this new approach, you are simply defining the path to have more control of the output.

:heart:If this response helped you, please click the heart to show that it is useful
:white_check_mark:If this response solved your issue, mark it as the solution to help the community