# Agent: RSI & Self-Tuning

**Page:** api/agent/rsi-tuning

[Download Raw Markdown](./api/agent/rsi-tuning.md)

---

{/* AUTO-GENERATED — Do not edit manually. Regenerate with: npm run docs:api:generate */}



The Agent RSI & Self-Tuning API powers two related self-improvement subsystems that run as background jobs with Server-Sent Events (SSE) progress streaming. Use these endpoints to start RSI (Recursive Self-Improvement) review passes and self-tuning runs against a session, then subscribe to the returned job's stream endpoint for live progress events.


The `*.stream` endpoints are GET requests that hold open a `text/event-stream` connection. Each emits a snapshot first (so late subscribers see current state) followed by live events. If the job is already terminal, the server emits the completion event and closes the connection.


## RSI (Recursive Self-Improvement)

The RSI subsystem runs a "Reviewer-Selected-Improvement" pass over a session transcript. Each configured reviewer model reads the transcript and emits findings. Start a review to receive a `jobID`, then stream that job for progress.

### Start an RSI review

`POST /api/v1/workspaces/{workspaceID}/sessions/{sessionID}/rsi/review`

Fan out a Reviewer-Selected-Improvement pass: each configured reviewer model reads the session transcript and emits findings. Returns a queued `jobID`; subscribe to `/rsi/runs/{jobID}/stream` for progress and final output.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier. |
| `sessionID` | path | string | Yes | Session identifier. |

#### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `focus` | string | No | Optional focus instructions appended to each reviewer prompt. Max 10K chars. |
| `reviewers` | array | No | Reviewers to run for this call. Each entry is either a string (filter by name into config) or an inline object that overrides config fields per-call. Omit to use all configured reviewers. Max 20 entries. |

When `reviewers` entries are inline objects, each accepts `name` (required, 1-64 chars), `model` (optional, `providerID/modelID` format), `fallbacks` (optional, up to 5 fallback models tried in order), and `prompt` (optional, overrides the configured prompt for this call only).

#### Example



```bash
curl -X POST "https://api.hoody.com/api/v1/workspaces/ws_alpha/sessions/sess_42/rsi/review" \
  -H "Authorization: Bearer $HOODY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "focus": "Focus on tool-call efficiency and final-answer correctness.",
    "reviewers": [
      "accuracy",
      { "name": "clarity", "prompt": "Be terse; max 200 words per finding." }
    ]
  }'
```


```ts
const { jobID, sessionID, status } = await client.agent.rsi.rsiReviewStart({
  workspaceID: "ws_alpha",
  sessionID: "sess_42",
  data: {
    focus: "Focus on tool-call efficiency and final-answer correctness.",
    reviewers: [
      "accuracy",
      { name: "clarity", prompt: "Be terse; max 200 words per finding." }
    ]
  }
});
```


```json
{
  "jobID": "rsi_01HQZ9X7K4G3D7M5B6V2R8NJTQ",
  "sessionID": "sess_42",
  "status": "queued"
}
```


```json
{
  "error": "RSI reviews are disabled for this workspace."
}
```


```json
{
  "error": "Rate limit exceeded; retry later.",
  "retryAfterMs": 30000
}
```



### Stream RSI review progress

`GET /api/v1/workspaces/{workspaceID}/sessions/{sessionID}/rsi/runs/{jobID}/stream`

Server-sent-events stream of progress events for an RSI review job. Emits a snapshot first (so late subscribers see current state), then live events; if the job is already terminal, emits the completion event and closes.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier. |
| `sessionID` | path | string | Yes | Session identifier. |
| `jobID` | path | string | Yes | Job identifier returned from the start endpoint. |

#### Example



```bash
curl -N "https://api.hoody.com/api/v1/workspaces/ws_alpha/sessions/sess_42/rsi/runs/rsi_01HQZ9X7K4G3D7M5B6V2R8NJTQ/stream" \
  -H "Authorization: Bearer $HOODY_API_KEY" \
  -H "Accept: text/event-stream"
```


```ts
const stream = await client.agent.rsi.rsiStream({
  workspaceID: "ws_alpha",
  sessionID: "sess_42",
  jobID: "rsi_01HQZ9X7K4G3D7M5B6V2R8NJTQ"
});

for await (const event of stream) {
  console.log(event.event, event.data);
}
```


```text
event: snapshot
data: {"jobID":"rsi_01HQZ9X7K4G3D7M5B6V2R8NJTQ","status":"running","completedReviewers":1,"totalReviewers":3}

event: reviewer.progress
data: {"reviewer":"accuracy","status":"done","findings":4}

event: done
data: {"jobID":"rsi_01HQZ9X7K4G3D7M5B6V2R8NJTQ","status":"succeeded","totalFindings":11}
```



## Self-Tuning

The self-tuning subsystem runs verifier-driven improvement loops on a session. Two modes are available:

- `tune` — single iterative loop, capped at 20 iterations.
- `amplify` — best-of-N loop with majority voting (N must be odd, max 11).

Both return a `jobID`; stream that job's progress via `/self-tuning/runs/{jobID}/stream`.

### Start a self-tuning tune run

`POST /api/v1/workspaces/{workspaceID}/sessions/{sessionID}/self-tuning/tune`

Run a single-iteration self-tuning loop against the session's verifier. Returns a queued `jobID`; subscribe to `/self-tuning/runs/{jobID}/stream` for progress and final output.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier. |
| `sessionID` | path | string | Yes | Session identifier. |

#### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `task` | string | Yes | The task / goal description for the tune run. Max 100K chars. |
| `verifier_name` | string | Yes | Name of a configured verifier program. Max 128 chars. |
| `max_iterations` | integer | No | Cap on iteration count (1-20). |
| `model` | object | No | Override the worker LLM for this call only. Requires `providerID` and `modelID`; both must already be configured or registered via `PATCH /config` beforehand. |

#### Example



```bash
curl -X POST "https://api.hoody.com/api/v1/workspaces/ws_alpha/sessions/sess_42/self-tuning/tune" \
  -H "Authorization: Bearer $HOODY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Reduce average tool-call latency below 1.2s while preserving task success rate.",
    "verifier_name": "perf_v1",
    "max_iterations": 8,
    "model": { "providerID": "openai", "modelID": "gpt-4o-mini" }
  }'
```


```ts
const { jobID, sessionID, status } = await client.agent.selfTuning.selfTuningTuneStart({
  workspaceID: "ws_alpha",
  sessionID: "sess_42",
  data: {
    task: "Reduce average tool-call latency below 1.2s while preserving task success rate.",
    verifier_name: "perf_v1",
    max_iterations: 8,
    model: { providerID: "openai", modelID: "gpt-4o-mini" }
  }
});
```


```json
{
  "jobID": "tune_01HQZA3K8N5F2P4Q7M9B6V3WYX",
  "sessionID": "sess_42",
  "status": "queued"
}
```


```json
{
  "error": "Self-tuning is not enabled for this workspace."
}
```


```json
{
  "error": "Rate limit exceeded; retry later.",
  "retryAfterMs": 60000
}
```



### Start a self-tuning amplify run

`POST /api/v1/workspaces/{workspaceID}/sessions/{sessionID}/self-tuning/amplify`

Run a best-of-N amplify loop against the session's verifier (N must be odd, max 11, for majority voting). Returns a queued `jobID`; subscribe to `/self-tuning/runs/{jobID}/stream` for progress.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier. |
| `sessionID` | path | string | Yes | Session identifier. |

#### Request Body

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `task` | string | Yes | The task / goal description for the amplify run. Max 100K chars. |
| `verifier_name` | string | Yes | Name of a configured verifier program. Max 128 chars. |
| `n` | integer | Yes | Number of trials (odd, max 11) for majority voting. |
| `model` | object | No | Override the worker LLM for this call only. Requires `providerID` and `modelID`; both must already be configured or registered via `PATCH /config` beforehand. |

#### Example



```bash
curl -X POST "https://api.hoody.com/api/v1/workspaces/ws_alpha/sessions/sess_42/self-tuning/amplify" \
  -H "Authorization: Bearer $HOODY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Generate a SQL query that lists the top 10 customers by lifetime spend.",
    "verifier_name": "sql_v1",
    "n": 5,
    "model": { "providerID": "anthropic", "modelID": "claude-3-5-sonnet" }
  }'
```


```ts
const { jobID, sessionID, status } = await client.agent.selfTuning.selfTuningAmplifyStart({
  workspaceID: "ws_alpha",
  sessionID: "sess_42",
  data: {
    task: "Generate a SQL query that lists the top 10 customers by lifetime spend.",
    verifier_name: "sql_v1",
    n: 5,
    model: { providerID: "anthropic", modelID: "claude-3-5-sonnet" }
  }
});
```


```json
{
  "jobID": "amp_01HQZB5M2P7H4R6T9K1C8X4ZGB",
  "sessionID": "sess_42",
  "status": "queued"
}
```



### Stream self-tuning run progress

`GET /api/v1/workspaces/{workspaceID}/sessions/{sessionID}/self-tuning/runs/{jobID}/stream`

Server-sent-events stream of progress events for a self-tuning tune or amplify job. Emits a snapshot first (so late subscribers see current state), then live events; if the job is already terminal, emits the completion event and closes.

#### Parameters

| Name | In | Type | Required | Description |
|------|-----|------|----------|-------------|
| `workspaceID` | path | string | Yes | Workspace identifier. |
| `sessionID` | path | string | Yes | Session identifier. |
| `jobID` | path | string | Yes | Job identifier returned from the tune or amplify start endpoint. |

#### Example



```bash
curl -N "https://api.hoody.com/api/v1/workspaces/ws_alpha/sessions/sess_42/self-tuning/runs/tune_01HQZA3K8N5F2P4Q7M9B6V3WYX/stream" \
  -H "Authorization: Bearer $HOODY_API_KEY" \
  -H "Accept: text/event-stream"
```


```ts
const stream = await client.agent.selfTuning.selfTuningStream({
  workspaceID: "ws_alpha",
  sessionID: "sess_42",
  jobID: "tune_01HQZA3K8N5F2P4Q7M9B6V3WYX"
});

for await (const event of stream) {
  console.log(event.event, event.data);
}
```


```text
event: snapshot
data: {"jobID":"tune_01HQZA3K8N5F2P4Q7M9B6V3WYX","status":"running","iteration":3,"maxIterations":8}

event: iteration.done
data: {"iteration":3,"verifierScore":0.82,"bestSoFar":true}

event: done
data: {"jobID":"tune_01HQZA3K8N5F2P4Q7M9B6V3WYX","status":"succeeded","bestScore":0.91}
```