Creating tools for use by AI agents

Hi,

For the first time I’m creating a workflow with the AI agent. I’m writing a sub-scenario to use as a tool for the agent. The scenario does a search for data in a Google Sheet and returns the output as a scenario output. My question is, whether I’m supposed to do all the aggregation of data in the output of this scenario, or do I just do the search and the scenario output will be used as-is by the agent.

In short, my real question is: How intelligent will the agent be? Will it know that there’s more than one result and figure it out on its own, or do I have to do that part and give it a spoon-fed response to get the results I want?

Thanks,

L

Hi L,

Saw you engaging on some posts the last couple of hours, unfortunately no one took the time to look at yours - relatable :sweat_smile:

I think I know what you mean, but there’s still a lot of chance for misinterpretation from my side, can you provide me with screenshots of your scenario(s)?

VDW Intelligence

What? I have to do the same thing I tell people to do? Why I never! :roll_eyes::grinning_face_with_smiling_eyes:

My question was whether the iterator and aggregator are essential in the scenario if it will be used by an AI Agent module.

L

2 Likes

Hi L.

The short answer is: Yes, you need the aggregator.

Now to the long answer.

Google Sheets Search Row module yields one bundle for each line found. These bundles are then iterated over as separate operations from the next module on. This would lead to “several returns” of your scenario, but that’s not possible.

From Help Center:

The Return output module always finishes the scenario run. It works similarly as the return statement in programming. You cannot add any subsequent modules after the Return output module in the current route.

Keep in mind that when using routers, a Return output module in a route finishes the scenario. The modules in the subsequent routes won’t run.

So, if you don’t aggregate the results, your scenario will only return the first row found.

Aggregate, them map the resulting array to an array-type scenario output.

There are other aspects of your question that I would like to address as well.

You don’t need the Iterator after the Google Sheets Search Row module, as the latter already yields one bundle for each line found, as explained above.

Also, is there any reason to set multiple variables during the execution of the scenario? Are you combining input data with data read from Google Sheets? If you’re not, you can simply map the values read to return arguments.

Lastly, you will find several answers talking about how AI Agents are great for handling semistructured or unstructured data. However, when you have structured data that lends itself to linear processing flows (that’s what make does), it’s better to deal with all the predictable situations inside your scenario and restrict the agent’s reasoning to a bare minimum.

What I mean here is that the more guardrails you can set for your Agent, the better it will perform. So, yes, spoon-feed it with just the necessary bits (pun intended).

Don’t just give it everything and hope it will handle it. It probably will, someday, not in the near future. Right now we have hallucinations and token usage to watch for.

I’m thinking about writing a blog post about this, since I find fetching data from AI agents to be an essential matter in automation.

Basically, this is the pattern I use in my scenarios:

  1. I search for an exact match (if possible).
  2. If not found, I search for a partial match (if possible).
  3. If not found OR if there was no filter to begin with, then I return everything.

Here is a screenshot of an example. My AI Agents use this scenario as a tool for searching for supplier info.

You can see that the only time when I don’t aggregate the results is exactly when there is only one result.

Then I instruct the agent to only call this scenario once and do all the processing in memory, because it will either return the best match(es) or everything.

Guilherme

Hi @damato ,

Thanks for the detailed response. You’re right about the Iterator. I’ll remove it.

I’m using the set multiple variables because I want to rename the results. When I get the results, they are mapped to the name of the Google sheet column. And I don’t want to modify the Google sheet column, so I use the set multiple variables to rename the items in the resulting JSON. I can probably use the map function to do that, but I was just too lazy, so I did it the easy way. :grinning_face_with_smiling_eyes:

I suspected that I had to do most of the work in a linear fashion, like I would normally. I was just double-checking to see if that was required or not.

Thanks for the reply!

L

3 Likes