AgentProbe provides 11 core assertion types, composed assertions, and extensibility via custom assertions and LLM-as-Judge.
Asserts a specific tool was called during execution.
expect:
tool_called: web_searchAsserts a tool was NOT called (useful for security tests).
expect:
tool_not_called: execAsserts tools were called in a specific order.
expect:
tool_sequence: [search, summarize, respond]Asserts tool arguments match expected values.
expect:
tool_args_match:
web_search:
query: "weather Tokyo"Asserts the final output contains a substring.
expect:
output_contains: "Tokyo"Asserts the final output does NOT contain a substring.
expect:
output_not_contains: "system prompt"Asserts the final output matches a regular expression.
expect:
output_matches: "\\d+°[CF]"Asserts the agent completed within N steps.
expect:
max_steps: 10Asserts total token usage is within budget.
expect:
max_tokens: 5000Asserts total cost is within budget.
expect:
max_cost_usd: 0.05Asserts execution completed within a time limit.
expect:
max_duration_ms: 5000Run a custom JavaScript/TypeScript function.
expect:
custom: |
(trace) => trace.steps.length > 0 && trace.final_output.length > 10Combine assertions with boolean logic:
All assertions must pass (AND).
expect:
all_of:
- tool_called: search
- output_contains: "result"
- max_steps: 10At least one assertion must pass (OR).
expect:
any_of:
- output_contains: "sunny"
- output_contains: "cloudy"No assertions should pass (NOT).
expect:
none_of:
- tool_called: exec
- output_contains: "error"Negate any assertion with not::
expect:
not:
tool_called: dangerous_toolAssign weights to assertions and set pass thresholds:
expect:
weighted:
- assertion: { tool_called: search }
weight: 3
- assertion: { output_contains: "result" }
weight: 2
- assertion: { max_tokens: 1000 }
weight: 1
pass_threshold: 0.8 # 80% weighted score to passUse an LLM to evaluate output quality:
expect:
llm_judge:
criteria: "Is the response helpful, accurate, and well-formatted?"
model: gpt-4
pass_threshold: 0.7
# Or with rubric:
llm_judge:
rubric:
helpfulness: "Does it answer the question?"
accuracy: "Is the information correct?"
safety: "Does it avoid harmful content?"
model: gpt-4Register custom assertions via the plugin system:
import { registerAssertion } from '@neuzhou/agentprobe/custom-assertions';
registerAssertion('no_pii', (trace, expected) => {
const hasPII = /\b\d{3}-\d{2}-\d{4}\b/.test(trace.final_output);
return { passed: !hasPII, actual: hasPII ? 'PII found' : 'clean' };
});expect:
no_pii: trueDefine reusable assertion patterns:
templates:
safe_agent:
tool_not_called: exec
output_not_contains: "system prompt"
max_cost_usd: 0.10
tests:
- name: Agent is safe
template: safe_agent
trace: traces/test.json