Test Tools Safely with Mocks
Open in CMSOnce your agent calls tools (your own API, an MCP server, another agent or a plugin), testing gets harder: a test run could read live data that changes every day, write to a real system, or fail because a service is down. Mocks fix that. In this step you write scripted answers for your tools, attach them to a scenario, and run it, so every run gets the same predictable tool results and nothing real is touched.
In this tutorial you test how Atlas, Kirana Group's operations assistant, reports project status. Atlas looks up projects with the Custom API get_project_status from Connect Your API. The real project data changes as work moves on, so you pin it down with a mock set: KG-2041 is always On hold at the CFO stage, and every other code returns 404 Not Found. Then you run a two-step scenario against it.
AI is still involved. The mock returns exactly the same tool answer every time, but Atlas decides when to call the tool and writes the reply, and AI judges every criterion. Those can differ from run to run, so read one result as a sample.
Before you start
- You have the Owner or Contributor role on the agent. Anyone with either role can use Simulation.
- Your agent has at least one tool: Connect Your API, Connect an MCP Server, Work With Other Agents or a plugin from Using Plugins. To follow along, Atlas has the
get_project_statusAPI. - The agent is published, so you can run against Published like the other pages in this step. The mock editor lists the tools of the draft and the published agent together, so a tool you only saved in the draft can be mocked too. See Preview and Publish Changes.
- You know the basics of scenarios (steps, expected responses, criteria). If not, read Build Your First Test Suite and Write Good Scenarios first.
- Tool Mocks and Tool Policy appear under Simulation in the agent sidebar. If you don't see them, the feature is not switched on for your CMS yet.
Why use mocks
During a simulation, every tool call goes through a gate that decides what happens to it. Without mocks, each kind of tool has a fixed default:
| Tool | Default in a simulation (no mock) |
|---|---|
| Custom API, MCP server, other agents and A2A peers | Blocked: no call is made and the agent gets a policy error instead of a result. You can change this for the whole agent in Choose Which Tools Run Live. |
| Plugins that read data (for example Dynamic Table, Public Documents, or recalling a memory) | Live: the real call runs and returns real data. |
| Plugins and built-in tools that write data (forms, reminders, saving or forgetting a memory, escalation) | Simulated: no real call; the agent gets an empty "success" answer. |
| Web search and web scraping | Live, and they cannot be mocked. |
So without mocks, a scenario that depends on Atlas's Projects API can never pass, and a scenario that reads a live table can pass today and fail tomorrow. A mock gives the tool a scripted answer instead. That lets you:
- Test without touching real systems or real data. No real project records, no writes to a production system, no calls to a paid API.
- Get the same result on every run, so a failing run means the agent changed, not the data.
- Test the hard paths on purpose: an empty result, a "not found", a 500 error, a timeout, a project that is on hold. These are difficult to trigger with a real service.
Key terms
| Term | Meaning |
|---|---|
| Mock set | A named collection of scripted answers for one or more tools. Library sets are shared and can be reused by any scenario of the agent. |
| Tool mock | The part of a mock set for one tool. The editor shows it as one card per tool. |
| Case | One scripted answer for a tool, used when the call's arguments match the case's conditions. A tool can have up to 50 cases, checked from top to bottom. |
| Condition | A rule on one input of the call, such as projectCode is KG-2041. All conditions of a case must hold. |
| Otherwise | What a tool answers when none of its cases match. It can give a default response, give it ahead of the sets listed below, or pass the call on to the next mock set. |
Step 1: Create a mock set
- In the CMS, open Simulation → Tool Mocks in the agent sidebar. The page is titled Tool Mocks.
- Click New Mock Set.
The editor opens with the title New Mock Set and a Library chip. The Library chip means this set is shared: you can attach it to any scenario of this agent. There is nothing to name yet. The editor is empty and says No Tools Mocked Yet, with an Add Tool button. The name comes later, when you save, and the CMS suggests one for you.

After you save the set and open it again, the title also shows Used in 0 scenarios, which changes once you attach the set in Step 6, a Duplicate button that makes a copy of the whole set, and a Mock Set Information card at the top where you can change the Name and Description.
Step 2: Add the tool you want to mock
- Click Add Tool.
- Search for
get_project_statusin the Search tools… box and click it. The list shows the tools of the draft and the published agent together, grouped by source (Custom API, Plugins, MCP, Other agents, A2A, Built-in). Each entry shows what the tool does with data and what it would do in a simulation if you don't mock it: Blocked unless mocked, Runs live unless mocked or Simulated success. For example, searching forescalateshows the built-inescalate_conversationtool with the labels Writes data and Simulated success. A Draft Only or Published Only chip shows when the tool exists in just one version of the agent.

The tool appears as a card, open, with its name, a one-line summary and a small ⓘ button. Click ⓘ (About This Tool) to read its type (Custom API, GET), its description and its Inputs, the arguments the AI fills in when it calls the tool. For get_project_status there is one input, projectCode.

You can add several tools to one set. The cards stack, and only one is open at a time: opening one closes the others.
If a tool is later removed from the agent, its card shows Tool not found in the draft or published agent. Use Re-Bind to… to move its cases to another tool.
Step 3: Add a case with conditions
- In the open card, click Add Case. The case opens with one condition already added, on the first required input of the tool. Give the case a label so you recognize it later, in Label this case (optional):
KG-2041 is on hold. - Under When all of these match, the condition row shows the input
projectCodeand the comparison is. TypeKG-2041as the value. Under the row, the CMS shows the input's description from the API ("Kirana project code in the form KG-0000, for example KG-2041. Use upper case.") to help you type a valid value. - To match on more, click Add Condition. The case only answers when every condition holds. Inputs you don't list can have any value.
A tool can have only one condition per input. When every input already has one, Add Condition turns grey, and hovering it explains why. To answer for either of two values, use the comparison is one of on that one condition, or add another case: separate cases work as "or".

The comparisons you can choose depend on the input's type:
| Input type | Comparisons |
|---|---|
| Text (also lists, objects and unknown types) | is, is not, contains, starts with, ends with, matches pattern, is one of, is empty, is not empty |
| Number | =, ≠, <, ≤, >, ≥, is between (inclusive) |
| Yes/no | is true, is false |
Tips:
- Text comparisons ignore upper and lower case unless you switch on Aa (match case) on the condition. So
kg-2041also matches this case. Aa only shows for the comparisons it affects, such as is, contains or matches pattern. - is one of takes a comma-separated list; is between takes a minimum and a maximum.
- matches pattern uses a regular expression.
- A case needs at least one condition. To answer every call, use the Otherwise block in step 5, not a case.
- With two or more cases, a hint above them says "Cases are checked from top to bottom. The first one that matches answers. Drag to reorder." Order matters, so put the most specific case first. The ? button next to Add Case (How Cases Work) explains the same.
- For unusual inputs, open Advanced — Match Raw Arguments and paste a piece of JSON the call's arguments must contain. It is checked in addition to the conditions.
Step 4: Write the response
A new case starts with an empty response. Under Respond with, write what the tool returns for this case. For Atlas, keep the status 200 OK, choose JSON and paste:
{
"projectCode": "KG-2041",
"name": "Surabaya warehouse expansion",
"status": "On hold",
"percentComplete": 62,
"approval": {
"stage": "CFO",
"nextApprover": null
},
"latestUpdate": "Paused by the CFO until the revised steel quotation is approved."
}
The editor adapts to the tool:
- For a Custom API, choose the HTTP status in the field next to Respond with (default 200 OK). Error codes in the 5xx range reach the agent as an empty result, just like a real failing API.
- The switch at the right of the row picks how you write the body: JSON | Text for a Custom API, or Form | JSON and Form | Text for tools that have a form that fits their output (for example rows and columns for a table query, or the reply text of another agent).
- Template opens a menu of ready-made starting points, grouped Success and Error. For a Custom API the Error group has Service down or timed out, Not found (404), Unauthorized (401), Rate limited (429) and Invalid request (400). For a table query it has Query fails and No rows found. Picking one fills the response once. Nothing stays tied to the template.
- For an MCP tool, choose Content or MCP error.
- Suggest lets AI draft a response and shows it in a Suggested Response preview, written for this case's conditions (here, for KG-2041). Nothing changes until you click Use This Suggestion, or Try Again for another draft. It differs every time, so read it before you keep it.
- Use a Real Response calls the real tool once, read-only, so you can copy its shape. It appears only for tools that only read data: a Custom API that uses GET, or a plugin read such as SQL Database Reader, Dynamic Table or Public Documents. There is one field per input, filled from the case's is conditions where it can. Click Call, read the result, then Use This Response (or, for rows and columns, Use Columns Only or Use Columns and Rows). A real call can return real data, and using it stores that data in the mock, so check it first.
- Format pretty-prints the JSON, which is handy after you paste a body.
Response bodies can be up to 64 KB.
Step 5: Decide what happens to every other call
Below the cases, the Otherwise, every other call returns block decides what the tool answers when none of its cases match. (On a tool with no cases yet, the same block is titled Every call returns.) For Atlas, every other project code should look unknown:
- Click the block to open it. Only one case or this block is open at a time.
- Open Template, and under Error pick Not found (404), or set the status to 404 Not Found yourself.
- Make sure the body is
{"error":"Not found"}in JSON mode. - Click More Options to see the three choices, as in the picture below, but keep the default, Use only when no other set answers. It is the right choice for a set that is the only one mocking this tool.

More Options matters when a scenario attaches several mock sets that mock the same tool. Under "If another mock set on the scenario also mocks this tool", you choose how this set's Otherwise ranks against the others:
- Use only when no other set answers (the default): this answer is used for calls that no case in any attached set matched. If several sets answer this way, the one listed first wins.
- Use ahead of sets listed below: this answer covers every call this set's cases didn't match, before the cases of the sets listed below this one. Sets listed above still check their cases first. This is how a step takes a tool over completely.
- Don't answer; pass to the next set: calls this set's cases didn't match go to the next attached set, then to the tool's policy. The response box is hidden, since this set gives no answer.
Step 6 explains what "listed below" and "checked first" mean for a scenario.
Before you save, try the mock. Next to Add Case, click Try a Call. The panel shows one field per input (or a JSON view through the Enter as switch). Type KG-2041 in projectCode and click Test. The result reads "Matches case 1: KG-2041 is on hold". Try KG-9999: it reads "No case matched — the Otherwise answered.", and the panel lists why case 1 was skipped. Nothing is sent to the real tool.

Try a Call checks this one tool in this one set. In a real run, a matching case in another attached set can answer first, as step 6 explains.
Now click Save. A Save Mock Set dialog opens, with the text "We named it after its tools. Change it if you like."
- In Name (required, up to 120 characters), replace the suggested
get_project_statuswithProjects API: KG-2041 on hold. - In Description (optional), write
get_project_status returns a fixed "On hold" answer for KG-2041 and 404 for any other code. - Click Save.

The CMS says "Mock set created successfully" and takes you back to the Tool Mocks page. The set now appears there with its description, 1 tool · 1 case, the tool chip get_project_status, and how many scenarios use it.
The screenshots on this page may show names that end in 2, such as Projects API: KG-2041 on hold 2, because the demo agent already held items with the same names. Use the names as written above.

Step 6: Attach the mock set to a scenario
- Open Simulation → Scenarios, select the folder Kirana Projects from Build Your First Test Suite, click New Scenario and write a scenario with two steps. See Write Good Scenarios for the details.
- Step 1, user message:
What is the status of project KG-2041? - Step 2, user message:
And project KG-9999?
- Step 1, user message:
- Add the expected responses, then click Suggest All Criteria to let AI write the evaluation criteria for every step. Review them and remove any you don't want.
- Open Advanced Setup. On a wide screen, click the Setup icon on the left of the form (Show Advanced Setup). On a narrower screen, click the Advanced Setup card below the steps. It is optional, and it holds Date and Time, Tool Mocks and Agent Tools. Open Tool Mocks and click Add Mock Set:
- From Library… attaches a shared set. In the Add from library panel, tick
Projects API: KG-2041 on holdand click Add 1 mock set. - Create New makes a Private set that belongs only to this scenario. It opens the same editor in a side panel, with Apply instead of Save, and names the set for you.
- From Library… attaches a shared set. In the Add from library panel, tick
- Click Save. The Scenario Information dialog asks for a Scenario Name and a Folder. Enter
Project status: KG-2041 on hold, unknown code, keep the folder Kirana Projects (if you skipped the first page of this step, Qlar offers Default), and click Continue. Then click Yes to "Are you sure you want to create this scenario?" and Close on the success message.

In the same Advanced Setup, Agent Tools sums up what will happen to every tool of Atlas in this scenario. For Atlas it reads something like "3 will be blocked", followed by how many tools are mocked, live and simulated, with a coloured bar and the chips Mocked, Simulated, Live and Blocked. Click Review Tools to open What the agent's tools will do, with one row per tool. get_project_status has a Mocked chip. Ledger and the two MCP tools have a Blocked chip, because a tool of those types is blocked by default until a mock, a Tool Policy setting or an Allow Live… says otherwise. Hover a chip to read the reason. On a mocked tool, click Check Order to see, in order, which cases and which Otherwise would answer a call to it.

Things to know:
- Sets attached in the setup are used by every step. Drag the rows to change their order.
- Each step also has its own Tool Mocks (n) section with Add Mock Set, closed until you open it. A step's own sets are checked before the scenario's sets, so you can change one tool's answer for a single step (for example "the first lookup finds nothing, the second one finds the project"). The link What will each tool do in this step? in that section shows the effect for that step.
- Date and Time in Advanced Setup: by default the agent sees the real time. Turn on Fixed date & time to set the Date & time and the Time zone for this scenario. Use it when tool arguments depend on dates ("tomorrow"), so the conditions keep matching on every run.
- Edit on a library set opens it on the Tool Mocks page in a new tab. Because the set is shared, changes there apply to every scenario that uses it. Edit on a private set opens it in a side panel. In the row's ⋮ menu, Make a Private Copy (on a library set) gives this scenario its own copy that you can change without affecting other scenarios, and Save to Library (on a private set) shares it with the rest of the agent's simulations.
When several mock sets mock the same tool, a call to that tool is answered in this order:
- Every attached set's cases come first. Qlar checks the cases of this step's sets from top to bottom, then the scenario's sets from top to bottom. The first case that matches answers. The order of the list decides, not how specific a case is, so a case in a set higher up wins even when a lower set has a more exact one.
- Then the first Otherwise that answers. If no case matched anywhere, the first set whose Otherwise gives an answer (Use only when no other set answers) is used.
- Then the tool's policy. If every set passes the call on, what the Tool Policy says for that tool happens: blocked, live or simulated.
A set whose Otherwise is Use ahead of sets listed below answers before the cases of the sets under it. That is how a step takes a tool over completely: give the step its own set for the tool and choose that option. For Atlas, which has a single set, the order is simple: case 1 for KG-2041, then the Otherwise (404) for everything else.
Step 7: Run the simulation
Back on the Scenarios tab, click Run on the scenario's card. The confirmation asks Are you sure you want to run the scenario "Project status: KG-2041 on hold, unknown code"?. Under Run against, choose Published.
If the run could reach tools that are blocked in simulations and have no mock, the confirmation also lists them. For Atlas it says the run "will hit 3 blocked tools. A blocked tool returns a policy error instead of running, so any step that needs it will fail.": Ledger (the agent from Work With Other Agents) and resolve-library-id and query-docs (the tools from Connect an MCP Server). The line after it adds: "To test those steps, cancel and open the scenario, then mock the tools (or allow them live) under "Tool Mocks". Otherwise choose "Run Anyway" to continue without them." The confirm button now reads Run Anyway.

These questions are about project status, so Atlas should not need any of those tools. Click Run Anyway. If a scenario does depend on a blocked tool, click Cancel and add a mock for it first, or open the scenario and click Mock It next to the tool. Which tools show as blocked also depends on the Tool Policy: see Choose Which Tools Run Live.
Check the result
- Click Close on the success message. Qlar opens the Simulation Result page, or you can open the run later from the Results tab (see Read the Results). The status row at the top reads Completed. Under Scenario (1) (the word is singular for one scenario), the scenario row shows its folder, 2/2 Steps completed, the duration (here 19 s, which varies from run to run), and 5/6 Matched. The folder is Kirana Projects if you followed Build Your First Test Suite, or Default if you skipped it.

- Click Mocks used in this run to open a read-only panel with the exact mock sets the run used, frozen at the time of the run. At the top, CLOCK says whether the run used real time or a simulated clock, and LIVE TOOLS says which tools were allowed to run live: here None, "Every tool call was mocked". Under them, each set is labelled with where it applied, such as Scenario · #1, and lists its tools and their cases, as in the editor. Click the X at the top right to close the panel.

- Close the panel, open the scenario, expand Step #1 and open Tool calls. The call
custom:get_project_statuswith the argumentprojectCode: KG-2041shows the chip Mocked. The line underneath starts with the status200, then names the case by the start of its id followed by its label, for exampleCase e1246ed2… 'KG-2041 is on hold', then the mock setProjects API: KG-2041 on hold 2, and ends with Scenario-level mock set. Above the list, the header reads Tool calls (1) with a Mocked 1 chip, and "Tool calls are listed in the order the agent made them."

Each call is a numbered card with an outcome chip and a line that says where its answer came from:
| Outcome | What happened |
|---|---|
| Mocked | A mock set answered. If a case matched, the line underneath names the case and the mock set, plus the status code, and ends with Step-level mock set or Scenario-level mock set. If no case matched and a set's Otherwise answered, the line reads "No case matched, used Otherwise". In Step #2, the call for KG-9999 is answered this way with the 404. |
| Simulated | No mock answered; the tool's built-in simulated success was used. |
| Live | The real tool ran. These rows carry a warning that they may contain real data. |
| Blocked | No call was made. Use Mock This Call to add a mock for it. |
| Internal Tool | An internal tool that always runs. |
| Unknown | Qlar could not tell what happened to the call. |
When no mock answered, the line names the rule that decided instead: Tool policy, Allowed live in this scenario or Built-in default, which is what the tool's type does when no Tool Policy setting covers it. Tools in Simulations explains each one.
Expand a call to see the full Arguments and Response. Above them, Checked before the answer lists every case Qlar tried before the one that answered, and why each one was skipped. If the tool has a Response Prompt, the row notes that it was applied on top of the mocked response, just as in production. On a Mocked or Live call, Save as Case turns the call into a new case (in a private set for this step, for the whole scenario, or in an existing set), which is the quickest way to build mocks from real behavior.
- Look at the step's answer and criteria. In Step #1, Atlas reports the status On hold at approval stage CFO, 62% complete, and the latest update from the mock. Three of the four criteria match, each in a green box with a quote. The one that fails is a grey box, The answer identifies KG-2041 as the Surabaya warehouse expansion project.: the reason under it says that the answer does not identify KG-2041 as that project.

This is exactly what simulations are for. The mocked data was correct, so the failure points at the agent, not at the data. Atlas's Response Prompt tells it to start with the status and the approval stage, so it never says which project it is talking about. A reader with three projects open could mix them up. You can fix it in the Response Prompt of get_project_status (for example, "Start with the project code and name, then the status and the current approval stage..."), check it on Draft as shown in Test Changes Before You Publish, publish, and run the scenario again until it shows 6/6 Matched. Notice also the line "Budget spent vs. total: Not provided": the mock has no budget fields, and Atlas says so instead of inventing numbers.
- Expand Step #2. The call for
KG-9999matches no case, so the Otherwise answers with 404, and Atlas says the code is unknown and asks the user to check it, as the API's Rules tell it to. Expand the call: under Checked before the answer, Qlar lists case 1, "KG-2041 is on hold", and why it was skipped, for exampleprojectCode is "KG-9999", expected "KG-2041". Both criteria of this step match.

If the result is not what you expect:
- The call shows Blocked instead of Mocked. The mock set is not attached to this scenario or step, you did not save the scenario, or it mocks a different tool. Check the Tool Mocks section and the tool name.
- The call says "No case matched, used Otherwise" for KG-2041. The condition does not match the argument the AI sent. Expand the call, read Checked before the answer, compare the Arguments with the condition, and check whether Aa (match case) is on.
- A case from a set lower in the list is not answering. A case in a set higher in the list matched first. Cases are checked across all attached sets before any Otherwise. Open Check Order on the tool in What the agent's tools will do to see the order.
- A note says "Answered under the previous mock rule". The run is older than the current matching order, where a set's Otherwise ended the search. Run it again to get today's order.
- A note says what is shown may differ from runs. The CMS and the simulation service are briefly on different matching versions. Run the scenario again after a moment, and trust the run result over Try a Call.
- The tool is missing from Add Tool. Save the tool on the agent first. A tool that only exists in the draft shows a Draft Only chip, and one that only exists in the published agent shows Published Only.
Limits and good practice
- Mocks only apply to simulations. Preview, the published agent and real channels always call the real tools. Mocks do not change your live agent, so there is nothing to publish for them.
- A mock set holds up to 50 tools, each tool up to 50 cases, each case up to 20 conditions.
- Web search and web scraping cannot be mocked; they run live in simulations.
- Mocks are tied to a tool. If you remove a tool from the agent, its mock shows Tool not found in the draft or published agent, and Re-Bind to… moves its cases to another tool.
- Keep one purpose per mock set ("happy path", "API down", "project on hold") and combine sets per scenario, rather than one huge set. When you combine them, remember that the cases of every set are checked before any Otherwise.
- Always test at least one error path (the Error templates) so you know how your agent answers when a service fails. The 404 for
KG-9999above is one.
For the full list of fields on these screens, see the Help pages Tool Mocks, Scenarios and Results.
Next steps
- Next in this step: Choose Which Tools Run Live, to decide which of Atlas's tools may run for real in a test.
- The same feature in more depth: Tool Mocks and Tools in Simulations.
- Field-by-field reference: Tool Mocks, Scenarios and Results.
- Previous in this step: Build Your First Test Suite.