Check an automated test and adjust it¶
credencestack test makes every choice for you: how the agent is built, which simulated
tool serves each of its tools, which packs run. Most agents need no adjustment. This page
is for when a result looks wrong: how to tell a set-up problem from a real finding, and
how to fix each kind of problem by editing the agent file,
never your agent.
1. Run the checks alone first¶
credencestack test my_app.agent:agent --preflight
The checks:
- detect the agent, map its tools and choose the packs
- confirm that every tool can be intercepted and that the agent has a tool that acts (pays, clears, approves)
- confirm that the variables in
model_envare set - run one smoke episode
Nothing is graded and nothing is written except the agent file. A failed check stops here with its fix (see when something needs attention).
2. Read the tool map¶
The tool map is printed by every run and shown in the report under What was tested. For each of your tools it shows the simulated tool that serves it and how sure the match was. Check three things:
- Every tool that acts is served by the right action. A tool that pays must be
served as
pay_invoice, one that clears an alert asclear_alert, one that approves an application asapprove_onboarding. A wrong action here makes every result meaningless. - Read tools are served by the matching lookup. For example,
get_suppliershould be served aslookup_vendor, notlookup_invoice. - "not served" is right for tools outside the back office. A weather lookup or your CRM search is not served, and calls to it answer "not available in the CredenceStack test environment". Calls to such tools are listed in the report, and are never findings.
Matches below a confidence of 0.55 are left unmapped rather than guessed.
3. Fix a mapping¶
Open credencestack-agent.toml and edit the tool's entry. Entries are used exactly as
written; the next run reads them.
A tool served as the wrong simulated tool:
[[tools]]
tool = "fetch_counterparty"
sim = "lookup_vendor" # was lookup_invoice
args = { vendor_id = "counterparty_id" }
A tool CredenceStack should not serve:
[[tools]]
tool = "search_crm"
sim = ""
An argument with another name, unit or source. args maps each argument of the
simulated tool to where its value comes from:
[[tools]]
tool = "create_payment"
sim = "pay_invoice"
args = { invoice_id = "bill_id", amount = "amount_cents/100", idempotency_key = "request_id" }
"bill_id": your tool's argument of that name."amount_cents/100": your argument divided by 100 (amounts in minor units)."task.invoice_id": a value from the task's inputs, for a tool that does not take it.
If an argument cannot be translated during the run (a value is missing, or a number cannot be read), the episode is not graded. It is listed as a set-up note that names the tool and the argument.
4. Check the packs and what was not tested¶
The report's What was tested section says which domains were recognised and why
(tools such as pay_invoice, words such as "invoice" and "supplier").
- Too many packs, or the wrong ones: pass
--pack(for example--pack docintegrity), or editpacks = [...]in the agent file. - Too few: say what the agent does in one sentence with
--describe "reviews sanctions alerts on held payments", or delete thepacksline so the next run chooses again.
Not tested lists the scenarios that did not apply, each with the reason:
- needs get_balance, which no agent tool serves: the agent has no such tool. Map one of its tools if it really does that, or accept it.
- a kill-switch scenario: the agent cannot be stopped from outside: name your stop
function with
stop = "my_app.control:stop"in the agent file (it receives the reason). Strands agents can be stopped without one. - its expected outcome depends on limits that differ in your profile: shown with
--profilefor scenarios whose outcome depends on limits your profile does not define.
None of these count against the agent.
5. Tell set-up notes from findings¶
Every episode gets a label:
- behaviour: the agent ran and was graded.
- set-up: something on your side stopped it: a missing key, an import error, an argument that could not be translated.
- infrastructure: a rate limit, a timeout or a server error. Such an episode is retried twice before it gets this label, as long as the agent had not yet called a tool.
Only behaviour episodes count. Set-up and infrastructure episodes are listed under
Set-up notes, each with its fix. If they are more than one in ten, the assessment's
status is setup_incomplete, the report says the run could not exercise the agent, and
it shows no findings. --fail-on does not fail such a run. Fix the notes and run again.
6. Look at one episode¶
When a finding surprises you, open the episode's trace:
fixed/report.html(orforge/report.htmlfor generated scenarios) shows every tool call, its arguments and result, the approvals, and the graders' verdicts.fixed/traces/holds the same as JSON lines.assessment.jsonhas the same rows as the report, for scripts.
Check that the agent's call, as translated, says what the agent meant. If it does, the finding is real. If it does not, fix the mapping (step 3).
The report also says how many decisions were read from the agent's words rather than from what it did. A high count usually means the acting tool is not mapped.
7. Run it again, narrowly¶
Each suggestion in the report ends with the command that runs its scenarios again:
credencestack test my_app.agent:agent --scenario PAY-005 --scenario PAY-007 --no-forge --yes
When the narrow run looks right, run the whole test again, then --mode standard before
you rely on the rates.
Agent services¶
For an agent deployed behind a URL, the same steps apply. Also check the [service]
section:
format:openaifor a chat-completions endpoint,jsonfor one field in and one out.fieldandreply: the request and response fields.openapi: the document of the back-office API the service calls. Every operation becomes one of its tools, mapped as above.
The service must read the back-office URL from configuration, so that it calls the API CredenceStack serves. See a deployed service.