# Close the continuous self-improvement loop safely

URL: https://docs.hanzo.ai/docs/guides/science/recursive-harness-improvement

> Combine local Hanzo Dev memory consolidation, Kai agent.learn@1 outcome hooks, and versioned study gates into a safe recursive improvement loop.

**Make everyday coding and operations compound into stronger memory, skills, tools, and agent harnesses.** Recursive improvement works only when every proposed upgrade is scoped, evidence-backed, and reviewable.

## Architecture & contract

Local memory consolidation extracts reusable preferences without falling back to billed foreground models; Kai's `agent.learn@1` chooses `none`, `memory`, `experiment`, or `improvement` after verified tool turns; harness changes ship strictly as draft PRs validated on held-out evals.

**Primary endpoint:** `GET /v1/research/runs` · \*_Status:_\* `preview` · \*_Level:_\* `fellow`

## Run it across all four surfaces

**CLI**

```bash
# Enable independent local memory route in Hanzo Dev
dev memory enable --base-url http://127.0.0.1:8731/v1 --model zen6-flash
dev memory status

# Inspect live org AI metrics to track repeat-failure reduction
hanzo eval metrics
```

**SDK**

**TypeScript**

```ts
import { Configuration, EvalApi, AiApi } from 'hanzoai';

const cfg = new Configuration({ accessToken: process.env.HANZO_API_KEY });
const [metrics, feedback] = await Promise.all([
  new EvalApi(cfg).getEvalMetrics('7d'),
  new AiApi(cfg).postAiFeedback({ request_id: 'chatcmpl-01J...', signal: 'accept' }),
]);
console.log({ metrics: metrics.data, feedback: feedback.data });
```

**Python**

```python
import os
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import EvalApi, AiApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
print(EvalApi(client).get_eval_metrics(range="7d"))
print(AiApi(client).post_ai_feedback({"request_id": "chatcmpl-01J...", "signal": "accept"}))
```

**HTTP**

```bash
# Inspect public research record and org 7-day trend
curl -s "https://api.hanzo.ai/v1/research/runs?limit=5" | jq '.'
curl -s "https://api.hanzo.ai/v1/eval/metrics?range=7d" \
  -H "Authorization: Bearer $HANZO_API_KEY" | jq '.'
```

**MCP**

```bash
curl -s -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "eval",
      "arguments": {"op": "get_eval_runs", "input": {}}
    }
  }'
```

## Verify the outcome

- Verify `dev memory status` reports active independent local consolidation.
- Confirm `kai.toml` sets `[ops.learn] mode = "advisory"` until shadow accuracy clears your bar.

## Production guardrails

- Keep person, workspace, and shared product scopes strictly isolated — private sessions never become shared training corpora.

## Next steps & Hanzo University

- [Continuous Improvement](https://docs.hanzo.ai/docs/science/continuous-improvement) · [Self-Improvement](https://docs.hanzo.ai/docs/self-improvement)

- **[SCI 401 — Recursive Improvement](https://hanzo.university/recursive-improvement)** ([Launch interactive lab on hanzo.app/learn](https://hanzo.app/learn/recursive-improvement))

- **[AUTO 101 — Continuous Improvement](https://hanzo.university/continuous-improvement)** ([Launch interactive lab on hanzo.app/learn](https://hanzo.app/learn/continuous-improvement))
