Guardrails and Evaluation
Kompile exposes guardrails and evaluation at two layers, matching its two runtime surfaces:
- CLI & MCP Agent Harness (runs locally with zero server required) — Enforcer & Judge policies, Command Guardrails, the LLM Tool Gateway, agent evaluation suites (
eval), the model performance harness (perf), and test milestones. - Distributed Server (
kompile-app) (runs on the admin console:8080) — RAG input/output content guardrails (kompile-guardrails) and dataset A/B experiments (kompile-evaluation).
Part 1: CLI & MCP Harness Guardrails & Evaluation
Harness Guardrail Layers
The coding-agent harness layers deterministic checks and LLM-backed oversight around tool execution:
| Layer | Where it runs | How to inspect or configure |
|---|---|---|
| Deterministic Enforcer & Hooks | Every tool call in kompile chat, kompile mcp-stdio, and kompile serve | /judge, /policy-enforce, /hooks — see The Enforcer |
| Inline Compliance & Direction Judge | Tool calls, turn completions, and subagent runs | /judge, /judge-global, /direction — see The Judge |
Command Guardrails (CommandGuardrail) | Shell command regex rules (.kompile/config/command-guardrails.json, ~/.kompile/config/command-guardrails.json, or built-in defaults) | /gateway status, /gateway rules |
LLM Tool Gateway (CliToolGatewayInterceptor) | Evaluates non-read-only tool calls (ALLOW / REWRITE / BLOCK) before execution across kompile chat, kompile mcp-stdio, and kompile serve | /gateway (alias /guardrails), kompile configure gateway, kompile config tool-gateway |
| Periodic Transcript Audits | Out-of-band session review | /policy-enforce — see Auditing & Provenance |
Tool Gateway (CLI & MCP)
The Tool Gateway evaluates proposed tool calls against user-defined rules before execution and can ALLOW, REWRITE arguments, or BLOCK the call with corrective feedback.
- Cheap, local read-only tools (
read,grep,glob,list) always bypass LLM network evaluation so everyday search never stalls. - Disabled by default until enabled in
~/.kompile/config/tool-gateway-config.json(orfeature-flags-config.json), adding zero overhead when off. - Rules live in
~/.kompile/config/tool-gateway-rules.json(shared with the server-sideToolGatewayServiceformat).
# Interactive setup wizard from the terminal
kompile configure gateway
# Inspect or update gateway settings
kompile config tool-gatewayInside kompile chat:
/gateway status # Show Tool Gateway state + active Command Guardrail source
/gateway rules # List Tool Gateway rules and Command Guardrail patterns
/gateway setup # Launch the interactive Tool Gateway wizard and hot-reload
/gateway reload # Reload tool-gateway-config.json and rules without restarting
/guardrails # Alias for /gatewayConfiguration options: model source, fail-open behavior, dry-run mode, evaluation timeout, and per-rule conditions/actions.
Agent Evaluation Suites (eval)
The CLI evaluation harness runs structured YAML/JSON suites against coding agents, tracks pass/fail outcomes, optionally scores completions with a judge LLM, and stores historical runs for trend and side-by-side comparison.
It is exposed across all three harness surfaces:
- CLI:
kompile eval ... - Interactive chat:
/eval ... - MCP tool (
kompile mcp-stdioandkompile serve):eval(list_suites,list_runs,show_run,inspect_suite,create_suite,compare_runs,trend,delete_run)
# Scaffold and validate a suite file
kompile eval create my-suite.yaml
kompile eval inspect my-suite.yaml
# Run an evaluation suite against an agent (optionally with judge scoring)
kompile eval run my-suite.yaml --agent claude-code --judge
# Inspect historical results and compare runs
kompile eval list
kompile eval report --suite "My Suite"
kompile eval show <run-id>
kompile eval compare <run-id-a> <run-id-b>
kompile eval delete <run-id>Inside kompile chat:
/eval list # List discovered suite files
/eval report [suite-name] # Show past evaluation runs
/eval show <run-id> # Inspect one stored run
/eval inspect <suite.yaml> # Validate and summarize a suite file
/eval create <suite.yaml> [name] # Scaffold a new suite file
/eval compare <run-a> <run-b> # Compare two runs side by side
/eval trend <suite-name> # Show pass-rate trend over time
/eval delete <run-id> # Delete a stored runPerformance Harness (perf)
Track model and agent performance across task types, view leaderboards, and query recommendations. Exposed via:
- CLI:
kompile perf [report|recommend|config|reset] - Interactive chat:
/perf [report [task]|recommend [task]|config|stats|reset --yes] - MCP tool:
performance_harness(record,report,recommend,stats,config,reset)
kompile perf report # View performance leaderboard
kompile perf recommend # Get model/agent recommendations
kompile perf config # View or update tracking settings
kompile perf reset # Clear collected recordsTest Milestones
For day-to-day verification inside coding sessions, /test-milestones and the test_milestone MCP tool automatically capture test executions and record structured pass/fail verification milestones alongside your session transcript.
Part 2: Server-Side (kompile-app) RAG Guardrails & Experiments
When running the distributed server (kompile-app-main on :8080), Kompile adds RAG content guardrails (kompile-guardrails) and dataset experiments (kompile-evaluation) around retrieval and chat pipelines.
Input guardrails
| Guardrail | What it detects |
|---|---|
| Prompt injection | Attempts to override system instructions |
| Jailbreak | Attempts to bypass safety filters |
| PII detection | Personal identifiable information in queries |
| Toxicity | Toxic or abusive language |
| Topic | Off-topic queries |
| Business rule | Violations of custom business rules |
| Competitor mention | References to competitors |
| Copyright | Copyrighted content |
Output guardrails
| Guardrail | What it detects |
|---|---|
| Hallucination | Responses not supported by retrieved context |
| Relevancy | Responses that don't address the query |
| Format | Responses that don't match expected format |
Server guardrail configuration
Each server-side guardrail can be toggled individually on the admin console (:8080):
# Via REST API
curl -X POST http://localhost:8080/api/guardrails/toggle \
-H "Content-Type: application/json" \
-d '{"guardrailType": "PROMPT_INJECTION", "enabled": true}'
# View guardrail status
curl http://localhost:8080/api/guardrailsYou can also toggle them in the web UI (Settings > Guardrails) or via feature-flags-config.json.
Server-side experiments
Experiments group RAG evaluation datasets and runs for A/B testing on the admin console (:8080):
# List experiments
curl http://localhost:8080/api/experiments
# Create an experiment
curl -X POST http://localhost:8080/api/experiments \
-H "Content-Type: application/json" \
-d '{"name": "Compare embedding models", "datasetId": "<id>"}'Scheduled evaluation
Run evaluation suites on a schedule to detect regressions:
kompile app schedule create --type=eval --cron="0 0 * * *" --suite=my-suiteWhen to use guardrails & evaluation
Guardrails add latency whenever an LLM or classifier evaluates a turn. Enable them selectively:
- Coding-agent sessions: keep deterministic Enforcer rules on; add the Judge or Tool Gateway when you want policy enforcement or argument rewriting on shell/edit tools
- External RAG users: prompt injection, jailbreak, PII
- Regulated domains: business rules, copyright, competitor mention
- Production RAG: hallucination, relevancy
- Internal dev loops: keep heavy server-side content guardrails off unless testing them
Run evaluations when you:
- Change prompts, agent instructions, or model failover ladders
- Change the embedding model, chunking strategy, query transformation, or reranking settings
- Add or remove data sources
- Want to compare LLM providers or coding agents objectively
Related concepts
- Why Kompile Is Opinionated — how the harness layers deterministic guards, judges, and audits
- The Enforcer & The Judge — coding-agent policy rules and live compliance supervision
- Information Retrieval — server-side guardrails wrap the retrieval pipeline; experiments measure its quality
- Configuration —
tool-gateway-config.json,tool-gateway-rules.json,command-guardrails.json, andfeature-flags-config.json