totebot CLI: find what is wrong, propose changes with evidence, test them without saving, apply only what you approve, check the results, and roll back if they got worse. This page is the human-readable version of “Recipe: optimize my agents” in totebot ai-guide, the Claude Code skill and AGENTS.md, which all hold the same steps.
The same checks power AI Lab in the dashboard. For the dashboard version of the loop, see Optimize your agent.
Set up
1
Install the CLI and sign in
Follow Totebot CLI, then teach Claude Code the CLI as in Use the CLI with coding agents.
2
Choose what the key may do
Start read-only. The agent can then analyse and propose, and nothing changes. Turn on write scopes under Team settings → API keys → Edit access only when you want it to apply changes.
3
Ask
For example: “Optimize the Shop agent. Show me what you would change and why before you change anything.”
The recipe
1. Analyse
reportis one overview: outcomes, revenue, credits, knowledge, the test pass rate and the top gaps. Use--all-agentsfor the whole team.analyse outcomesgives per week the handover rate, thumbs-up rate, how often the agent answered without a search, empty searches, ticket resolution time, conversion rate and revenue. The agent looks for the weeks that got worse.agents readinessis the checklist on the AI Lab Findings tab: failed and expired knowledge, knowledge no search returned in 30 days, open gaps, the test pass rate, whether “Check knowledge before every answer” is on, and model advice (credit multiplier, search rate, thumbs-down rate and credits per conversation per model).eventsandagents revisionsshow what happened lately and which settings changed.knowledge listshows each source’svalidFrom/validUntil. An expired promotion is fixed withtotebot knowledge set-dates <agent> <source> --valid-until <date>if the offer still runs, or deleted if it is over. A new time-limited offer gets--valid-untiltoo, so the agent stops using it on time.
2. Check the instructions
suggestedPrompt has every edit applied: it is a suggestion to show you, never something to save on its own. Findings marked requiresHumanReview add links, contact details, discounts or offers, and are applied only with your explicit OK. Results are cached for 24 hours per prompt, and there is a daily limit.
3. Propose
The agent writes a short list of concrete changes, each with its evidence: Q&A or text to add with exact wording, sources to retry, remove or re-date, instruction edits as a diff, a model change with credits per conversation before and after, and settings. It checks its own draft too, and makes sure there are test questions for what it changes:4. Test before applying
before.jsonkeeps the live instructions and model id.tests runwith--prompt-fileor--modelruns your test questions against the proposal without saving it, and compares it with the live agent. Exit code 10 means the pass rate fell below the threshold; exit code 11 means the test run itself failed.chatasks one question with the proposal and returns the reply and the steps behind it. No conversation is created, customers never see it, and it is billed like a dashboard preview (200 per key per day).- Optional:
totebot experiments start <agent> --name "Shorter prompt" --percent 20 --prompt-file proposed.md --yes --jsonsends 20% of new conversations to the proposal (see Experiments). Experiments are turned on per workspace: contact support to enable them. Real customers see it, so the agent runs it only after the test run passed and you agreed; without a terminal it needs--yes.
5. Apply
Only what you approved, with a preview first:--model when only the instructions change, and --prompt-file when only the model changes, so you apply exactly what you tested.
The dry run prints changes, each field before and after. Without a terminal, agents update needs --yes; the agent passes it only after you approved that change. Train after knowledge changes. Every write is recorded in the audit log under the key’s name and kept as a revision.
6. Verify
agents readiness, compares analyse outcomes for the weeks before and after, follows totebot events --follow --json, and for an experiment reads totebot experiments report <agent> <experiment> --json (thumbs-down rate, handover rate, no-search rate and credits per conversation for CONTROL and CANDIDATE). Small samples prove little, and it says so.
7. Roll back if it got worse
experiments stop ends an experiment. For a saved change, agents rollback puts back the settings from just before that revision: pick the revision of the change you made, not simply the newest, in case something else changed since. The dry run prints changes as { field: { from, to } } and skippedFields: settings a rollback leaves alone, such as AI features only Totebot support changes, auto-retrain and gap digest emails, and anything your plan no longer includes. The rollback is a revision too, so it can be undone. Revisions cover settings, not knowledge: knowledge changes are undone with knowledge update or knowledge delete, then training.
In CI
Keep the instructions and test questions in git, and fail the pipeline when a change breaks the answers that matter:TOTEBOT_API_KEY in the CI secrets, with only the scopes the job needs. See Test questions.