Skip to main content
Agents are non-deterministic, so testing them starts with exercising behavior, not writing a perfect assertion. The fastest loop is often to have your coding agent prompt the Luno OS agent through the CLI, try realistic scenarios, inspect the resulting sessions, and iterate on the system instructions and tools. Test agents at the boundary you care about: Start qualitatively, then turn the stable contracts you discover into tests. Automated tests are best for definition shape, required tool calls, and a small number of critical prompt paths. Run tests from the project root:
Vitest ships with @meetluno/cli. No project vitest.config.ts is required.

Qualitative tests

Before writing test files, run the agent the way you expect people to use it. Ask your coding agent to call the Luno OS CLI with a batch of prompts, inspect the sessions, and report where the agent misunderstood instructions, skipped tools, or used tools incorrectly.
--wait returns each completed session for review. For long prompts, choose a bounded wait with --timeout <seconds> and continue with agents sessions get <agent> <session-id> --wait if the session is still running. Good qualitative prompts cover:
  • Normal requests the agent should handle cleanly.
  • Tool-required requests where the agent must call an action, workflow, MCP tool, or subagent.
  • Missing-information cases where the agent should ask a clarifying question instead of guessing.
  • Follow-up messages in the same session.
  • Edge cases that should be refused, escalated, or handled cautiously.
Then inspect the session — start with a summary, then request richer detail if needed:
Use this loop to tune the system prompt, tools, skills, files, and model choice. Once the behavior feels right, write focused tests for the parts that should not regress.

Definition tests

Definition tests are fast and do not need provider keys.
Use this style to catch accidental model changes, missing tools, or prompt edits that remove required instructions.

Smoke-tests

The init template includes an agent integration test shaped like this:
The provider-key guard keeps local and CI runs from failing when real model credentials are not available. Match the guard to the agent’s model (or use AI_GATEWAY_API_KEY, which works for any catalog id). Run integration tests from the project root:
Integration tests load .env when present and skip when required keys (like AI_GATEWAY_API_KEY) are unset. Vitest and its config ship with @meetluno/cli — no project vitest.config.ts.

Tool use tests

When a tool call is the contract, assert on the recorded messages rather than only the final answer.
Keep the prompt narrow. Tests that ask for broad natural-language behavior are more likely to be flaky than tests that assert a specific tool contract.

Sessions and memory

Prompt tests create sessions. If a test should be repeatable, use a fresh session or disable memory on the agent under test:
If you need a multi-turn test, keep the returned sessionId and pass it to the next prompt:

Evals

Evals score real agent replies instead of asserting exact text. Put them in src/**/*.eval.ts and describe each suite with describeEval from @meetluno/luno/evals: every case prompts the agent with input, scores the reply with each scorer, and fails when any score (0–1) is under threshold (default 0.7). Scores and the judge’s reasons are printed per case.
src/agents/support.eval.ts
  • LLM-judged scorers (createAnswerRelevancyScorer, createRubricScorer, createToxicityScorer, …) take a judge model. Use gatewayModel("vendor/model") so the judge runs through the Luno OS gateway.
  • Code scorers such as createKeywordCoverageScorer() (how many of the prompt’s keywords the reply covers) and createToneScorer() need no model. createRubricScorer is binary: 1 only when every required criterion holds.
  • A case can carry groundTruth for comparison scorers (similarity, completeness), and createScorer builds a custom one. timeout sets the per-case limit (default 180 s).

Tool-call scorers

Scorers also see the tools the agent called (with their arguments), so you can check behavior, not only wording:
  • createToolCalledScorer({ tool }) — 1 when the agent called tool, 0 otherwise.
  • createToolArgsScorer({ tool, args }) — the share of the expected args the call matched (deep equality per key, extra args ignored); 0 when the tool was not called.
  • Mastra’s createToolCallAccuracyScorerCode({ expectedTool, strictMode?, expectedToolOrder? }), createToolCallAccuracyScorerLLM and createTrajectoryAccuracyScorerCode are re-exported too.
Expected args usually differ per input, so a case can add its own scorers:

Run and review

Run them with luno evals run, optionally filtered by file name (luno evals run support); extra arguments go to Vitest. Evals call real models (the agent and the judge) and cost money, so luno test never runs them. When the project is linked and you are logged in, luno evals run uploads every case (input, reply, tools called, each scorer’s score and reason) as one eval run; --name nightly labels it and --no-upload keeps results local. A failed upload only warns, and the exit code is still the tests’ one. Review the history with luno evals list [--agent <slug>] and luno evals get <run-id>, or in the dashboard’s project Evals tab: the mean score per scorer over time, the runs table, and each run’s cases with the judge’s reasons.

Failure inspection

When a prompt test fails, inspect the session before changing code:
For deployed agents, use Runs (/history) in the web app and filter to agent runs. The detail panel shows messages, tool calls, metadata, and trace data.

Next steps

Run agents

Prompt agents locally and inspect sessions from the CLI.

Agent runs

Debug failed sessions in the web app.

Actions as tools

Build deterministic tool contracts that are easier to test.

Deploy a project

Run tests before deploying changed agents.