# Arm outcome-triggered research autopilot loops

URL: https://docs.hanzo.ai/docs/guides/science/automated-research-loop

> Subscribe durable automations on POST /v1/auto/automations to research improvement.reviewed events and inspect public research runs on GET /v1/research/runs.

**Replace manual overnight scripts with event-driven Research Autopilot.** Whenever a study finishes scoring a baseline vs. candidate run, Hanzo wakes a sandboxed agent to investigate regressions or draft the next bounded experiment.

## Architecture & contract

The automation engine deduplicates `research / improvement.reviewed` events by exact evidence hash, injects study payloads as untrusted data, and enforces explicit `permissions: "ask"` so no autonomous research loop merges unreviewed code.

**Primary endpoint:** `POST /v1/auto/automations` · \*_Status:_\* `preview` · \*_Level:_\* `specialist`

## Run it across all four surfaces

**CLI**

```bash
hanzo auto automations create --data '{
  "name": "Harness regression investigator",
  "instructions": "Read the reviewed study evidence. Reproduce any regression in a sandbox and open a draft PR with measured proof.",
  "event": {"source": "research", "name": "improvement.reviewed"},
  "model": "zen6-coder",
  "permissions": "ask"
}'
hanzo auto automations list
```

**SDK**

**TypeScript**

```ts
import { Configuration, AutoApi } from 'hanzoai';

const auto = new AutoApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await auto.postAutoAutomations({
  name: 'Harness regression investigator',
  instructions: 'Read the reviewed study evidence. Reproduce any regression in a sandbox and open a draft PR.',
  event: { source: 'research', name: 'improvement.reviewed' },
  model: 'zen6-coder',
  permissions: 'ask',
});
console.log(data);
```

**Python**

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

api = AutoApi(ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"])))
print(api.post_auto_automations({
    "name": "Harness regression investigator",
    "instructions": "Read the reviewed study evidence. Reproduce any regression in a sandbox and open a draft PR.",
    "event": {"source": "research", "name": "improvement.reviewed"},
    "model": "zen6-coder",
    "permissions": "ask",
}))
```

**HTTP**

```bash
# 1. Inspect public published research runs (no key required)
curl -s "https://api.hanzo.ai/v1/research/runs?limit=5" | jq '.'

# 2. Arm an outcome-triggered research automation
curl -s -X POST https://api.hanzo.ai/v1/auto/automations \
  -H "Authorization: Bearer $HANZO_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "name": "Harness regression investigator",
    "instructions": "Read the reviewed study evidence. Reproduce any regression in a sandbox and open a draft PR.",
    "event": {"source": "research", "name": "improvement.reviewed"},
    "model": "zen6-coder",
    "permissions": "ask"
  }' | 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": "auto",
      "arguments": {"op": "get_auto_automations", "input": {}}
    }
  }'
```

## Verify the outcome

- Confirm the automation is armed (`GET /v1/auto/automations`) and trigger one dry run via `POST /v1/auto/automations/{id}/run`.

## Production guardrails

- Keep `permissions: "ask"` on every research automation; never grant silent production deploy tokens.

## Next steps & Hanzo University

- [Research Autopilot](https://docs.hanzo.ai/docs/science/research-autopilot) · [Self-Improvement](https://docs.hanzo.ai/docs/self-improvement)

- **[SCI 301 — Research Autopilot](https://hanzo.university/research-autopilot)** ([Launch interactive lab on hanzo.app/learn](https://hanzo.app/learn/research-autopilot))
