yaalalabs/agent-kernel/ak-test
Claude Code and agent skill by yaalalabs/agent-kernel
- community
Checking that the SKILL.md file is still in the repository.
Set up testing and debug common issues in Agent Kernel projects. This skill guides you through configuring the built-in test framework, writing agent tests, choosing test modes (score, llm, fallback), and troubleshooting common errors.
Install
npx vskill@latest install yaalalabs/agent-kernel/ak-testSKILL.md
Testing & Debugging
Use this skill to set up testing for your Agent Kernel project or debug issues.
Instructions for the Agent
Setting Up Tests
1. Add Test Dependencies
Update pyproject.toml:
Run uv sync to install test dependencies.
2. Choose a Test Mode
Create test-config.yaml in the directory you run tests from — it is a separate, un-nested file (no top-level test: key), loaded only when the test harness runs. A test: section left over in config.yaml is ignored:
| Mode | How it Works | Best For | |
|---|---|---|---|
| score | Deterministic string-match scoring (built-in deepeval: Scorer.quasi_exact_match_score; built-in opik: graded LevenshteinRatio; built-in jev has no score mode) | Deterministic responses, exact answers | |
| llm | LLM evaluates if response is semantically correct (deepeval and opik: GEval; jev: a hosted yes/no Noul question) | Open-ended responses, creative agents | |
| fallback | Tries score first, falls back to llm if score fails | General-purpose testing |
For llm mode, configure the llm model:
Evaluator backend: evaluator selects the scoring backend used by both score and llm modes — deepeval (the default, pip install "agentkernel[test]"), opik (pip install "agentkernel[opik]", Opik by Comet, runs entirely locally) and jev (pip install "agentkernel[jev]", hosted TypeSafe JEV judge: mode: llm only, needs TYPESAFE_API_KEY, sends the comparison text to api.typesafe.ai) are the three built-ins. Set it to a dotted path (e.g. my_evaluator.MyEvaluator) to bring your own AKEvaluator subclass instead:
2a. Bring Your Own Evaluator (optional)
Use this when none of the built-in evaluators' scoring fits your agent — e.g. deepeval's binary exact-match score mode is too strict and opik's graded LevenshteinRatio still doesn't capture what you need, or you want a judge call that doesn't depend on DeepEval/Opik/JEV at all, or a domain-specific rubric. No AK core change is required: any dotted path to an AKEvaluator subclass works as the evaluator: value, resolved the same way sandbox providers and session stores resolve their own bring-your-own backends.
- Create a module next to your test file (e.g.
my_evaluator.py) and subclassAKEvaluator,
importing the interface from agentkernel.test:
```python from agentkernel.test import ( AKEvaluationCase, AKEvaluationError, AKEvaluationResult, AKEvaluator, AKMissingInput, )
class MyEvaluator(AKEvaluator): def evaluate_by_score(self, case: AKEvaluationCase) -> AKEvaluationResult: if not case.expected: raise AKMissingInput("evaluate_by_score requires AKEvaluationCase.expected") score = ... # your deterministic, offline scoring logic return AKEvaluationResult( metric="my_metric", evaluator="my_evaluator", score=score, passed=score >= case.threshold, )
def evaluate_by_llm(self, case: AKEvaluationCase) -> AKEvaluationResult: if not case.expected: raise AKMissingInput("evaluate_by_llm requires AKEvaluationCase.expected") try: score = ... # your judge call (any LLM client — litellm, an SDK, a hosted judge) except Exception as exc: raise AKEvaluationError(f"judge call failed: {exc}") from exc return AKEvaluationResult( metric="my_llm_metric", evaluator="my_evaluator", score=score, passed=score >= case.threshold, ) ```
- Both methods are synchronous and must set
result.passedthemselves —Test.comparedecides
whether a failing passed is fatal (raises AssertionError) or, with return_metrics=True, returned to the caller; it never overrides passed.
- Follow the same error contract every evaluator (built-in or custom) must honor: raise
AKMissingInput if a required AKEvaluationCase field (usually expected) is missing; raise AKEvaluationError if your backend fails (bad credentials, transport error, unparseable judge output) — never return a 0.0 to stand in for a failure, since 0.0 must only ever mean "scored zero". If your evaluator only supports one of the two modes (e.g. judge-only, no offline scoring), raise AKMetricNotSupported from the other and set mode to the supported one (e.g. mode: llm) — fallback does not catch it, so the error propagates and the test fails.
- Point
test-config.yamlat it by dotted path —module_name.ClassName, resolved against the
module's location (next to your test file, since that's what's on sys.path under pytest's default import mode):
``yaml evaluator: my_evaluator.MyEvaluator ``
- No AK extra beyond
agentkernel[test]is needed unless your evaluator's own dependencies
(an LLM client, a scoring library) require one — each built-in's import (deepeval, opik, jev) lives entirely inside its own resolution branch, so a custom evaluator never pulls any in.
See examples/cli/custom-evaluator/ for a complete worked example — a stdlib-only Jaccard token-overlap scorer plus a raw litellm judge call, no DeepEval dependency at all — and `docs/docs/testing/cli-testing.md` for the reference documentation.
3. Write CLI Agent Tests
For agents running via CLI (demo.py):
Key patterns:
- Use
@pytest.mark.order(n)for sequential tests where context matters - Use
scope="session"fixtures so the agent stays running across tests expect()takes a list of acceptable answer patterns- The test framework uses the configured mode to compare responses
- Pass
return_metrics=Truetoexpect()(orTest.compare()) to get back an
AKEvaluationResult (score, evaluator, metric, reason) instead of raising AssertionError on a mismatch — useful for asserting on the score itself rather than just pass/fail
4. Write API Agent Tests
For agents running via REST API:
5. Run Tests
Debugging Common Issues
Issue: "No agents available"
Symptom: CLI shows "No agents available. Please load an agent module using !load."
Cause: The Module constructor was not called, so no agents are registered with Runtime.
Fix: Ensure your agent file calls the Module constructor:
Issue: Session state not persisting
Symptom: Agent doesn't remember context from previous messages.
Causes & Fixes:
- In-memory sessions (default): State is lost when the process restarts. Switch to Redis/DynamoDB/CosmosDB for persistence.
- Different session IDs: Ensure you're using the same
session_idacross requests. - Lambda cold starts: Session state must be stored externally. Use Redis or DynamoDB.
Check session config:
Issue: "ToolContext not available"
Symptom: RuntimeError: ToolContext is not set inside a tool function.
Cause: The tool is being called outside of the agent execution context.
Fix: Ensure tool functions are bound via the framework's ToolBuilder and called within agent execution. Don't call tool functions directly outside of Runtime.run().
Issue: Guardrail blocks all requests
Symptom: Every request returns a guardrail violation message.
Fixes:
- Check guardrail config — ensure
config_pathpoints to a valid JSON file - Review guardrail rules — thresholds may be too strict
- Check the guardrail model — ensure
modelfield is correct - Disable temporarily to isolate: set
enabled: falsein config
Issue: Import errors for framework packages
Symptom: ModuleNotFoundError: No module named 'agents' (or crewai, langgraph, etc.)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingak-py/src/agentkernel/skills/ak-test/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/yaalalabs/agent-kernel/ak-test)