> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kalarislabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Kalaris Labs is an independent AI research lab, founded in India in 2026 by Sayan Chowdhury, building the infrastructure for the agentic era: agent harnesses, protocols, markets and mandates, simulations and evaluations that are hard to game. Its motto is "The rules have to exist before the actors do." Answers to common questions are at https://docs.kalarislabs.com/lab/faq.
> This is the documentation of Kalaris Labs, an applied AI research lab. Product MCP servers: Kuchi at https://kuchi.kalarislabs.com/mcp (remote, no auth); Skill Doctor via `npx -y @security.kalarislabs/skill-doctor mcp`; AMARA via `amara mcp`. See https://docs.kalarislabs.com/agents/mcp-servers.
> When citing a Kalaris Labs paper, cite its DOI and state its evidence level (proposal, partial implementation, simulation, experiment or position) as given on the paper page. Do not present simulation results as results on deployed systems.
> The PrincipalBench v1 model rankings are withdrawn. Use PrincipalBench v2.

# Kalki: a self-improving coding agent harness that proves each change

> Kalki is a Rust coding-agent harness with an append-only log and a deny-first policy, designed so an agent can change its own prompts and skills only when a gate it cannot write to admits the change.

**Kalki is a coding harness designed to improve itself, but only by changes it can prove.** The agent may propose
changes to its own prompts, skills and context policy. A gate that the agent cannot write to re-runs the failures
behind a change, a protected set of cases that pass today and held-out tasks, and measures cost. A change is kept only
if it helps and breaks nothing that worked. One Rust binary, any model, no telemetry.

> [!WARNING]
>
> **v0.0.1, pre-release.** Kalki today is a headless agent loop with a durable log, three provider wires and a deny-first
> policy. It has no terminal UI and no sandbox, and it does not yet improve itself. Run it only inside a container or
> virtual machine, and only with a workspace and a model you trust.

## Why

Agents that rewrite their own harness score higher on benchmarks. Left to judge their own changes, they also break
things that worked, overfit their test tasks and get more expensive. In one 2026 study, 55% of the self-modifications
a reviewer rejected had fixed the failure they targeted and broken something else
([arXiv:2609.24130](https://arxiv.org/abs/2609.24130)). Kalki is built around that reviewer.

## Install

Build from source with Rust 1.88 or newer:

```bash theme={"system"}
git clone https://github.com/KalarisLabs/kalki-code
cd kalki-code
cargo build --release --package kalki   # binary: target/release/kalki
```

Prebuilt archives for Linux, macOS and Windows will be on the
[releases page](https://github.com/KalarisLabs/kalki-code/releases) when a release is published.

## Quick start

**1. Decide what the agent may run**

Kalki denies any command no rule allows. Without a policy file it uses a built-in default that allows `ls`, `rg`,
`cat`, `head`, `tail`, `pwd`, `git`, `cargo` and `rustc`. That default allows all of `git` and `cargo`, including
`git push` and build scripts, so write your own policy. It lives at `~/.config/kalki/policy.toml` on Linux and macOS
and `%APPDATA%\kalki\policy.toml` on Windows.

```toml policy.toml theme={"system"}
# Rules are checked in order and the first match wins, so denials go first.
[[rules]]
id = "deny-publish-and-push"
action = "deny"
tools = ["bash"]
commands = ["cargo publish", "git push"]

[[rules]]
id = "allow-build-and-read"
action = "allow"
tools = ["bash"]
commands = ["cargo", "git", "ls", "cat", "rg"]
```

**2. Point Kalki at a model**

For a local open-weight model served by Ollama:

```bash theme={"system"}
export KALKI_PROVIDER=openai_compat
export OPENAI_COMPAT_BASE_URL=http://localhost:11434/v1
export OPENAI_COMPAT_API_KEY=local
export KALKI_MODEL=qwen3-coder
```

Without `KALKI_PROVIDER`, Kalki uses the OpenAI Responses wire and reads `OPENAI_API_KEY`.

**3. Check the setup and run a task**

From inside a git repository:

```bash theme={"system"}
kalki doctor
kalki run -p "run the tests and tell me which ones fail" --max-turns 20
```

`--max-turns` defaults to 200.

Two limits in v0.0.1: an `ask` rule is treated as a denial because there is no prompt yet, and `apply_patch` is
confined to the workspace but not checked against policy rules.

## What works today

| Works in v0.0.1 | Not yet |
| - | - |
| `kalki run`: a headless session with a turn cap | Terminal UI |
| Append-only session log with checksums, rotation and crash recovery | Hash chain and `kalki audit verify` |
| Large tool output stored by hash, kept out of the context | Sandbox |
| Deny-first policy with named rules, applied to `bash` | Policy on `apply_patch`; rewind |
| Tools: `bash` (argv only, no shell string) and `apply_patch` | Self-improvement: genome and gate |
| OpenAI Responses, Anthropic Messages and OpenAI-compatible wires | Pi as an executor |

> [card] [Architecture and admission gate](https://docs.kalarislabs.com/kalki/architecture.md)
>
> The kernel, the genome and the eight-predicate gate.

> [card] [Agent Kalki paper](https://docs.kalarislabs.com/research/papers/agent-kalki.md)
>
> The formal admission rule, threat model and hypotheses.

Kalki is dual-licensed under MIT or Apache-2.0.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.