credencestack.assess¶
credencestack test: test an agent as it is built, with its own tools served from the
simulated back office, and say what to fix. It sits above connectors, runner, forge
and evidence, and uses each of them as a library; nothing below it imports it.
Responsibilities¶
- Detection (
detect.detect,drivers): load the target and recognise how it is built. The target can be: - a LangChain or LangGraph graph
- an OpenAI Agents SDK
Agent - a Google ADK agent
- a Strands
Agent - a Microsoft Agent Framework agent
- Claude Agent SDK options with SDK MCP tools
- a CrewAI crew or agent
- a from-scratch function with
TOOLSandSCHEMASbeside it - a CredenceStack connector factory (native: it takes
tools) - a URL
Each Driver finds the tools (ForeignTool: name, description, JSON Schema), the
instructions and the name, and knows how to run one task and, where the framework
allows, how to stop it.
- Interception (intercept): each tool's callable is replaced in place by a proxy
(functools.wraps, so signatures and docstrings survive). Inside an episode a context
variable holds the episode's EpisodeTools, and the proxy translates the call and
answers from the environment. Outside an episode the original function runs.
- The tool map (toolmap.build_map, translate_args): a deterministic match from
the agent's tool names, descriptions and arguments to the simulated tools.
- Matching uses a concept vocabulary, a rule per simulated tool, a read-verb guard,
argument synonyms and a specificity tiebreak.
- Matches under CONFIDENT (0.55) are left unmapped.
- Argument expressions: amount_cents/100, task.<key>.
- The decision (decision.infer_decision): what the agent decided, from what it did
(a stated JSON decision, a stop, a payment, an escalation) and, failing that, from its
words.
- The advisor (advisor.advise, select_applicable):
- domain scores, from the words in the prompt and three points per mapped domain tool
- the packs for each chosen domain, plus thirdparty when inbound tools are mapped
- the scenarios left out because they need a tool the agent does not have
- Outcome labels (outcomes.classify_error): every episode is labelled behaviour,
set-up or infrastructure, with a fix. Infrastructure errors are retried twice, with
backoff, before any tool call.
- Running (run.prepare, preflight_checks, smoke, plan, run_test):
1. the checks and one smoke episode
2. the fixed scenarios through evidence.pipeline.run_to_bundle
3. Forge generation at the mode's levels, then those scenarios
4. the assessment and its report
- Your own rules (run.apply_rules, same_side): with --profile or --policy,
each scenario's expected outcome is relabelled by forge.label. A scenario that cannot
be relabelled is kept only when every amount falls on the same side of every limit.
- The assessment (assessment.build_assessment, remediation.yaml):
- Wilson rates for the fixed and the generated scenarios, by pack, level and mutator
family
- finding rows
- suggestions ranked by severity weight × episodes × fragility, each with a control
for your systems, a framework feature and a prompt change
- status setup_incomplete when more than SETUP_SHARE_LIMIT (10%) of episodes did
not exercise the agent
- Backend mode (backend): for a deployed service, a REST mock built from its
OpenAPI document (or an MCP server from its tool list), started on backend_port, and
a ServiceConnector that talks to the chat endpoint (openai or json format).
Optionally the service itself is started from command.
- The agent file (agentfile): credencestack-agent.toml, written on the first run
and read as written afterwards.
Inputs and outputs¶
| In | Out |
|---|---|
A target (module:attr or a URL), TestOptions, an optional agent file, profile, policy, OpenAPI document or MCP tool list |
<out>/test-<id>/: fixed/ and forge/ run bundles, forge-scenarios/, assessment.json, report/assessment.{html,md}, manifest.json (kind test); the agent file |
Non-goals¶
- Changing the agent. Interception replaces callables for the duration of the process and answers the original's callers outside an episode exactly as before.
- Calling a model to map tools, choose packs or grade. Every choice is a rule, and is written to the agent file so a person can change it.
- Grading set-up. A set-up or infrastructure episode is never a finding.
Public API¶
| Name | Kind | Signature | Purpose | Errors | Effects |
|---|---|---|---|---|---|
MODES |
constant | MODES: dict of 3 |
what each --mode runs: fixed scenarios per pack, epochs, Forge levels and scenarios per level | - | - |
Plan |
model | Plan(fixed, skipped, epochs, levels, per_level, forge) |
What will run. | - | data |
Prepared |
model | Prepared(options, agent_file, detected, driver, toolmap, advice, stop, wrote_agent_file) |
The agent, its map and the advice, ready to plan and run. | - | data |
TestOptions |
model | TestOptions(target, mode, packs, describe, only, seed, forge, agent_file, …) |
What credencestack test was asked to do. |
- | data |
TestRun |
model | TestRun(path, assessment, report_files) |
What run_test wrote. |
- | data |
plan |
function | plan(p: Prepared) -> Plan |
The scenarios and the generation for the mode. | - | reads the packs; mutates the selected scenarios when a profile or policy is given |
preflight_checks |
function | preflight_checks(p: Prepared) -> list[Check] |
The checks that run before any episode. | - | pure (reads the prepared agent and the environment's variable names, never their values) |
prepare |
function | prepare(options: TestOptions) -> Prepared |
Detect, map, advise; write the agent file when there is none. | UsageError: the agent cannot be loaded. ConfigError: the agent file cannot be read. | imports the agent's module; writes the agent file when there is none |
run_test |
function | run_test(p: Prepared, pl: Plan, dest: Path, *, output_id: str, on_episode: Callable[[str, int], None] \| None = None, on_phase: Callable[[str], None] \| None = None) -> TestRun |
Run the plan into dest and write the assessment, its report and the manifest. |
- | runs the agent (which may call its model); writes fixed/, forge/, assessment.json, the report and the manifest |
Tests¶
tests/integration/test_assess_frameworks.pytests/unit/test_assess_core.py
Invariants and gotchas¶
- One episode at a time per process for services. One service serves every episode, so backend mode runs sequentially.
- The kill switch needs a stop: Strands agents are stoppable natively, the others
through
stop = "module:function"in the agent file; otherwise kill-switch scenarios are listed as not tested. - Relabelling happens before sampling, so
--profiledoes not leave a mode with fewer scenarios than it would have had. - Native targets (a connector factory that takes
tools) are mapped one to one; the rules never run for them. - Telemetry.
credencestack test --otelstarts the same telemetry asrun; each episode emits its scenario trace throughrunner.episode.