Skip to main content

Tracking, QA and Reporting with AI · Part 1: AI, MCP, and installing it yourself

Chapter 20.2 · 2 of 28 · 3 min

Tool calling and multi-step workflows

In the last chapter I said there are tools.

Free to read

In the last chapter I said there are tools. In this chapter you will see how that actually happens, because once you know this you can read errors.

What happens inside

A tool call happens in three steps.

One, at the start AI is given a list: which tools exist, what each one is called, which arguments each one takes. This list travels together with the question.

Two, instead of answering, AI sends back a request: "I want to run gtm_list_tags with these three arguments." It does not run anything itself; all it can do is ask.

Three, your client reads that request, actually runs the tool, and returns the result to AI. AI then reads that result and writes its answer.

Notice that third step. AI does not do anything with its own hands. Your client does. That means control over permissions sits with the client, not with AI. This one point is the entire foundation of the governance material in Part 5.

What multi-step means

A task often needs one tool after another, because the next one's argument comes from the previous one's answer.

A real GTM example. You ask "which GA4 event tags are in the test container". AI has to go through four steps.

First, the list of accounts, because the container's API path needs the account ID. Then the list of containers in that account, because the tag path needs the numeric container ID, and what you know is the public ID in the form GTM-KS3HC8BP, which the API does not accept. Then the list of workspaces in that container, because tags live inside a workspace. Then, finally, the list of tags.

Four calls, each one's answer the next one's input. That is a multi-step workflow, and AI arranges it by itself.

This is the single thing that saves me the most time. By hand I would have to look up IDs in four separate places. Tell AI once and it chains the four steps together itself.

Where it gets stuck

When a step in the middle of a multi-step run breaks, AI often guesses the next one and carries on.

A real incident. Fetching the workspace list for a container returned a 403. AI read that, then ran the next call with 1 as the workspace_id, because the default workspace in GTM often has a small ID. That time it worked. But it was a guess, and on another container the same guess would have hit the wrong ID and returned a 404.

So you want to see the tool output, not only the final answer. Almost every AI client has a way to show tool calls and their results on screen: sometimes you click on a tool call to open it, sometimes it is a verbose or debug setting.

Screenshot: A tool call opened in an AI client, with the tool name and arguments at the top and the returned JSON below

Steps

  1. Find where your AI client shows tool calls. Click on a tool call, or look in the client's documentation for the verbose output setting.
  2. Run a familiar tool, such as a time or file-reading tool, and check that you can see both the arguments and the result.
  3. Write down in a notebook how to open that view. You will go there again and again for the rest of this book.

What not to do

  • Do not trust AI's summary without looking at the tool call result. Errors creep in while the summary is being written, and the raw output does not contain them.
  • Do not hand over a task and switch to another tab until you know which tools it will run. In a multi-step workflow one wrong step sends the next three down the wrong path, and from the final answer you cannot tell where it started.

Proof

You have opened both the arguments of a tool call and the raw output it returned on screen in your client, and you know how to get back to that view.

Want the full chapter list, or to jump to another chapter?

All chapters in the book