> ## Documentation Index
> Fetch the complete documentation index at: https://docs.totebot.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimize your agent

> Find what to fix, try the change, check it, and undo it if it made things worse

Improving an agent is a loop: find what is wrong, propose a change, test it before customers see it, apply it, check the results, and roll it back if it made things worse. Totebot has a tool for each step, in the dashboard and in the API. You can follow the loop yourself, or let a coding agent such as Claude Code run it for you.

## The loop

**1. Find what to fix**

Open [AI Lab](https://docs.totebot.ai/dashboard/ai-lab.md) from your agent's sidebar. The **Findings** tab lists what is worth fixing, measured from your own conversations in the last 30 days: knowledge that failed to load or expired, knowledge no customer question found, questions the bot could not answer, how many test questions pass, and how often your model searches your knowledge.

For more detail:

* [Knowledge gaps](https://docs.totebot.ai/dashboard/knowledge-gaps.md) list the questions your agent answered badly, with the thumbs-downs and handovers behind them.
* [Analytics](https://docs.totebot.ai/dashboard/analytics.md) shows volume, quality and revenue for any date range.
* In the [live preview](https://docs.totebot.ai/dashboard/overview.md#see-how-the-agent-found-its-answer), **Show bot reasoning steps** shows what the agent searched for before each reply, or that it responded from memory.

**2. Propose a change**

Click **Check my instructions** on the Findings tab. An AI reviewer reads your instructions next to your knowledge and last month's results, and suggests exact edits: conflicting rules, facts that belong in knowledge, missing basics such as shipping or returns. Changes that add a link, contact details, a discount or an offer are marked **Check before using**.

For a missing answer, add a Q\&A or text in [Knowledge](https://docs.totebot.ai/dashboard/knowledge.md). For a dated offer, set **Use until** so the agent stops using it when the offer ends (see [Keeping knowledge current](https://docs.totebot.ai/dashboard/knowledge-updates.md)).

**3. Test it before it goes live**

**Start experiment** loads the change into a draft and opens the **Experiment** tab. Nothing is saved. Click **Ask both** to put the same question to the live agent and the draft side by side, and **Run test questions** to see which of your [test questions](https://docs.totebot.ai/dashboard/test-questions.md) the draft fixes or breaks.

To check the change on real customers before you switch, run an [experiment](https://docs.totebot.ai/dashboard/experiments.md): a share of new conversations gets the change, and you compare thumbs-down rate, handovers and credits per conversation with the current setup. Experiments are turned on per workspace: contact support to enable them.

**4. Apply it**

Click **Save to live agent** on the Experiment tab, or save in **Settings → AI**. If the draft fails a test question the live agent passes, Totebot asks you to confirm first. Train the agent after knowledge changes.

**5. Check the results**

Test questions run again after every training. After a few days of real conversations, look at the AI Lab findings, your knowledge gaps and Analytics again, and compare them with the weeks before the change.

**6. Roll back if it got worse**

**AI Lab → Notebook** lists every change to the instructions and settings, with the test result of changes saved from AI Lab. Click **Undo** on a change to put back the settings the agent had just before it. See [History and rollback](https://docs.totebot.ai/dashboard/history.md).

## Let Claude Code run the loop

The [Totebot CLI](https://docs.totebot.ai/cli/overview.md) gives a coding agent the same tools: the readiness checklist, the instructions check, test runs against an unsaved prompt or model, one-off preview chats, dry runs that show each change before and after, revisions and rollback. Ask it to "optimize my agents", and it follows the recipe in [Optimize your agents with Claude Code](https://docs.totebot.ai/cli/optimize-agents.md).

The key you give it decides what it may do. A read-only key can only analyse and propose. To let it apply changes, an owner turns on the write scopes it needs under **Team settings → API keys → Edit access**. Every change it makes is recorded in the [audit log](https://docs.totebot.ai/dashboard/audit-log.md) and in the AI Lab **Notebook** under the key's name.

## Good habits

* **Change one thing at a time.** If you change the instructions and the model together, you cannot tell which one helped.
* **Write a test question for every fix.** It keeps the fix from breaking again later.
* **Give a change a few days.** A handful of conversations proves little either way.
* **Keep facts in knowledge, not in the instructions.** Prices, pack sizes and dated offers are easier to update, and to date, as knowledge entries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.