So.
Yes, as well.
You know, the tools we've got left to put on, on our communications tools to send a push notification
and an email.
And you have a whole bunch of these tools in your toolbox now, and you should feel free to use any
of them if you would rather have it slack.
The decisions or telegram you the decisions, then go for it.
But we're gonna stick for what I do with the ones that I picked, which is my favorite pushover.
Let's add in pushover.
Pushover.
The pushover tool.
Here it is.
And we want it to send a push notification.
We're going to let the model decide what message to send us.
That becomes something that is part of this tool.
It gets to say what it's going to put in.
And we have to put in our user key here.
This is the one that's the begins with the letter U.
And obviously rather than reveal it, I'm going to just copy and paste it in right now and I will see
you in a sec.
Okay.
I added that in my my user token beginning with the U.
I also changed the priority to high priority because I think I needed to do that for it to make a noise
on my phone at least.
Okay.
And now the email tool.
So I press tools and I'm going to go to Gmail, consume the Gmail API.
Now this time I'm going to have it actually send an email for reals.
But you remember I was I was a bit hesitant to before because I want to give it too much power, but
this time we're going to fix it.
To send the email to me, I'll use my Gmail address, so it's going to have to send it to me, and we'll
call the subject a fixed subject.
It's going to be, um, equity Rebalancer trading decisions.
Oops.
Spell that right.
Decisions.
And the message we're going to let the model define the message.
It's going to be an HTML type email.
The model will define the message.
And that is how we will do it.
So I will save that.
Uh so that tool is now set.
And now with this I do believe we have all the other all the tools.
Let me press the clean up button, make it nice and tidy.
Uh, okay.
I'm actually I'm also I'm going to zoom out a bit which is the minus button.
There we go.
Maybe press the tiny button again and it makes everything fit a bit better.
Maybe I should do that one more time.
There we go.
Uh, I think it's zooming in every time I tidy as well.
Uh, okay, so we've got everything laid out.
I think we're almost ready to go.
There might be one more thing.
One more thing we can tweak to make it a bit better.
So over here in the portfolio I have added in another row what proportion is fixed income.
So we're now showing the equity and fixed income breakdown here.
And so for example if I put in 100 as the price here for everything it shows the portfolio would then
be 60 over 40.
And if after rebalancing we have uh 3322 then the portfolio would change its makeup a bit.
So this, this shows you how I've improved the spreadsheet to be as clear as possible.
And now along with that, there's a change that we can make to our workflow.
I'm opening up the tool to get the rows of the Google Sheet, and something I've glossed over always
up to this point has been this field tool description that we've left it set automatically.
If I change that to set manually, I'll show you what this is.
By default, this just says get rows in sheet in Google Sheets, which is information that goes to the
LM when it's deciding whether to use this tool or not.
Well, we can do better than that.
We paste in something I wrote earlier which says this tool provides details of the user's portfolio
in a Google Sheet.
It includes the positions the equity fixed income breakdown.
Use this tool to retrieve the Google Sheet to see the positions before updating the price and making
rebalancing decisions important.
You must also use this tool after rebalancing to check the breakdown achieves your goal.
If not, keep iterating.
So just being crystal clear about what we want the LM to do and using the tool description as a means
to do it.
And this is all part of good context engineering.
And I've also gone in to the AI agent, and I've gone to this user message prompt.
And I've just added in a little bit in here about important.
You must confirm you've achieved your goal.
And at the very end I've said it only respond okay when your mission is complete.
Uh, just just to, uh, really try and be be very concrete with it.
And this is the kind of thing that one keeps iterating on.
So, you know, you may be able to do better by changing this a bit more.
Um, okay.
But that seems like it's it's in a good place.
There is one more thing that I want to do to this AI agent.
I want to go down here to the options.
Click here and change max iterations.
This is how many times it's able to use tools and things before it says, okay, I've done enough.
I'm stopping here and it's by default at ten.
And that might not be enough for us.
So I'm going to bump it up to 30.
So there's plenty of iterations for it to be thinking through what it needs to do.
Okay.
And without further ado, we should give this thing a try.
Let's check that our portfolio is in good shape and press Execute Workflow.
And you know this this whole week is all about automation.
It's all about automating business process.
And this is a classic example of an automation.
We are taking something that is manually intensive today, and we're running an agent workflow to take
care of it for us, uh, automating a process which which, as I say, manually intensive, um, at
the moment and something which is ripe for this kind of solution for ten plus, uh, AI agent.
So it's often it's running and it's thinking about what to do.
And this is a moment where I might show you the executions tab, which is something which shows you
this detailed trace of what's happening in each of the executions.
And it's taking a minute to refresh.
Um, meanwhile, let's just come over here.
It's already though.
It's ahead of itself.
The, uh, the traces are catching up, but it's already come in and set all of the prices of everything
and is now thinking about the rebalancing.
Let's come back over here.
Here.
It shows that it's running.
It's been running for 50s.
It's not yet ready to show us the detail of what it's doing.
Um, we come back here, it's now updating rows.
Let's come back here.
We can see it's done some rebalancing.
It's just changed everything.
So it's now got to a 60 over 40 kind of breakdown.
Uh, and, um, I just got the push notification.
I just unlocked my phone in time for you to.
To hear that.
Here we go.
We've got the portfolio rebalanced to 6040.
That has been successful.
Our agents have all run.
It happened in a flash faster than the traces.
Everything ran.
It sent the message to pushover.
And now let's look at the results.
So here I am over on the executions page, and we can see that everything ran.
There's a tick by everything.
You can see these numbers here.
Uh, the OpenAI chat model was called ten times.
It used the tool to collect the sheets four times.
It used market stack to get share prices four times and it updated rows several times.
It, uh, both of the updates tools were used multiple times.
This is the the rebalancing.
And then and then again to uh, to there was one time to set the prices and then against rebalance,
then one more time to fix the rebalancing.
And then it sent the push notification and the email.
And here just for the proof of it is the email.
So I got the email with the rebalancing instructions and everything seemed to work nicely.
This is quite the sophisticated workflow that we had running here.
A lot happened.
Uh, we've been able to to show, um, how rich it is to describe these workflows, uh, and to get,
get something that that is able to run and achieve a task that is quite sophisticated.
Uh, and the proof, of course, is over here in our Google sheet showing the new quantity after rebalancing,
showing that it achieved the 6040 split that we wanted after rearranging our portfolio and keeping the
total value pretty, pretty close.
Uh, so that I'd say, is an excellent outcome.
I think we can declare victory on this.
And there's just a couple more ways that we can improve this a little bit.
Sorry.
Wait.
Just before we improve it, I want to show you a little bit more about this executions page.
So again, I went from the editor to the executions page.
I'm looking at the most recent execution, which is this good one.
You'll see I had some errors in the past running this as I fixed a few things.
Uh, and you may have done as well.
Uh, so the one other thing I wanted to show you, which is very helpful in finding errors, is that
you could see this visual like this of everything running with the numbers.
You can also click where it says logs.
Just there and up comes these logs that show each of the different calls that happened.
And then there's over here this overview or details tabs.
If you flip to details, you get to see at each point in this kind of trace exactly what happened,
what was called with what prompts and what it did.
So you can see here, for example, that that it gets it gets the row.
This is why it's, it's, it's making sure that the, the 6040 split was achieved.
And then it makes one more change to the quantity to the BND ticker to make sure that it achieves the
target.
So you can look through this and see what it's doing, why it's doing it with at each point with the
inputs and outputs at every, every point in, in this workflow.
And so this is very powerful debugging tools.
And if you're not getting the behavior that you want this is where you go.
You read your logs and then you come back and you tweak the prompts.
And it can be very iterative to get to a point where it's reliably getting you to the right outcomes.