Skip to content
Back to skills

Interaction Autonomy

ASecurity

Control agent autonomy with durable human-in-the-loop approval gates, agent-initiated user-input pauses, and runtime pause/resume/stop controls.

  • 33 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
ai-agentstypescriptgoshellreactrailsgitapi

Works with

  • terminal
  • api
  • mcp

Security analysis

A100/100

Scanned December 5, 2026

npx -y skills add tylerjrbuell/reactive-agents-ts --skill interaction-autonomy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Interaction Autonomy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Interaction Autonomy
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tylerjrbuell-interaction-autonomy/badge)](https://www.skillsdirectory.com/skills/tylerjrbuell-interaction-autonomy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: interaction-autonomy
description: Control agent autonomy with durable human-in-the-loop approval gates, agent-initiated user-input pauses, and runtime pause/resume/stop controls.
compatibility: Reactive Agents TypeScript projects using @reactive-agents/*
metadata:
  author: reactive-agents
  version: "2.0"
  tier: "capability"
---

# Interaction and Autonomy

## Agent objective

Produce a builder that inserts human oversight into an otherwise autonomous run — pausing for approval before risky tool calls, letting the agent ask the human a question mid-run, or exposing runtime pause/resume/stop controls.

## When to load this skill

- Requiring human approval before certain tool calls (file writes, sends, code execution)
- Letting the agent pause and ask the human for a decision, form, or confirmation
- Building a supervised deployment where a run can be reviewed and approved from another process
- Needing runtime pause/resume/stop controls on an in-flight run

## How autonomy is controlled

There is no single "mode" switch. Autonomy is shaped by three independent, opt-in mechanisms:

| Mechanism | Builder method | What it does |
|-----------|----------------|--------------|
| Approval gates | `.withApprovalPolicy({ mode: "detach" })` (+ `.withDurableRuns()` optional) | Named tool calls wait for human approve/deny |
| Agent-initiated input | `.withUserInteraction()` (+ `.withDurableRuns()` optional) | The agent can call `request_user_input` to ask the human |
| Runtime control | `.withKillSwitch()` | In-process `agent.pause()` / `resume()` / `stop()` / `terminate()` |

Approval gates and agent questions both wait **live** by default: the run blocks in process until `approveRun`/`denyRun`/`respondToInteraction` answers, then the same run continues. Add `.withDurableRuns()` when the answer may come from another process or must survive a crash: the run then pauses and the pause persists to a run store.

## Implementation baseline — durable approval gate

```ts
import { ReactiveAgents } from "@reactive-agents/runtime";

const agent = await ReactiveAgents.create()
  .withName("assistant")
  .withProvider("anthropic")
  .withReasoning({ defaultStrategy: "plan-execute-reflect", maxIterations: 20 })
  .withTools({ allowedTools: ["web-search", "file-read", "file-write"] })
  .withDurableRuns()                                 // optional for approvals: pauses survive restarts
  .withApprovalPolicy({
    tools: ["file-write"],                           // these calls wait for human approval
    mode: "detach",                                  // a person decides (durable pause here; live wait without durable runs)
  })
  .build();
```

## Key patterns

### Approval gates

Name the tool calls that must pause. When the agent tries to call one, the run pauses and returns control:

```ts
.withApprovalPolicy({
  tools: ["file-write", "send-email"],               // pause before any of these
  requireFor: (ctx) => ctx.iteration > 5,            // or gate by a predicate
  mode: "detach",                                    // "detach" = a person decides, "block" = onApprove decides
})
```

Note: tools whose definition declares `requiresApproval: true` (built-ins like `code-execute` / `file-write`, and the `shell-execute` terminal tool) are folded in automatically once any approval policy is configured — you do not have to list them by hand. So are tools registered after `build()`: MCP tools annotated `destructiveHint: true` or `readOnlyHint: false`, `.withAgentTool()` sub-agent tools (`requiresApproval` defaults to `true`) and `agent.registerTool()` tools with `requiresApproval: true`. An unannotated MCP tool is not gated by default; name it (`"server/tool"`) or use `requireFor`. The `code-action` strategy refuses a policy that gates a tool its sandbox can call, sets `commands` while `shell-execute` is callable, or sets `requireFor`; `codeActionApprovalConflict({ callableTools, policy })` from `reactive-agents` checks this before a run.

Gate shell calls by command with `commands`. A rule is a word prefix of a command segment (`"git push"` matches `git push origin main`; a bare `"*"` matches nothing). With the read-only `git` preset, a matched write asks for approval instead of being refused:

```ts
.withTools({ builtins: ["git"], workspace: repoDir })
.withApprovalPolicy({
  commands: ["git push"],                            // asks before any `git push ...`
  onApprove: ({ args }) => askHuman(args),           // block mode; no onApprove = refused
})
```

An approved push still needs credentials the sandboxed shell does not have (no credential helper, no SSH keys or agent), so only pushes to a local path or an unauthenticated remote succeed.

#### Resolving a paused run

A paused run returns `status: "awaiting-approval"` with a `pendingApproval` descriptor. Approve or deny it — from this process or any other with access to the run store:

```ts
const result = await agent.run("Refactor and save utils.ts");

if (result.status === "awaiting-approval" && result.pendingApproval) {
  const { runId } = result.pendingApproval;
  // ...human reviews the pending action...
  const final = await agent.approveRun(runId);       // resumes and runs to completion
  // or: await agent.denyRun(runId, "not allowed to touch that file");
}

// List everything currently awaiting approval (e.g. for an inbox UI):
const pending = await agent.listPendingApprovals();
```

#### Same-process convenience

To handle the pause→decide→resume loop in one call, pass an `onApproval` callback — `run()` returns the FINAL result and you never touch the runId:

```ts
const result = await agent.run("Refactor and save utils.ts", {
  onApproval: (pending) => {
    // pending = { runId, gateId, toolName, args }
    return pending.toolName === "file-write" && isSafePath(pending.args);
    // return a boolean, or { approve, reason }
  },
});
```

#### Live waits, gate ids, and timeouts

Without `.withDurableRuns()`, a `detach` policy waits live in the process; a stream shows `ApprovalRequested` and `agent.listPendingApprovals()` lists it. Parallel sub-agents ask under the root run id, so each pending item carries `gateId` and `subAgent` (the asking sub-agent's name). Answer exactly one gate:

```ts
for (const p of await agent.listPendingApprovals()) {
  // p = { runId, gateId, subAgent?, toolName, args, ... }
  await agent.approveRun(p.runId, { gateId: p.gateId });
  // or: await agent.denyRun(p.runId, "not now", { gateId: p.gateId });
}
```

`approveRun(runId)` with no `gateId` answers the oldest wait. Bound the wait with `timeoutMs` in the policy: `.withApprovalPolicy({ tools: ["file-write"], mode: "detach", timeoutMs: 60_000 })`. No decision in time denies the call and the model reads why. A live wait is gone if the process exits; use durable runs when that matters.

### Agent-initiated user input

`.withUserInteraction()` lets the model call the `request_user_input` tool to ask the human for a form, choice, or confirmation.

The preferred call is `questions: [{ id, prompt, type, options? }]` with `type` one of `text | single-choice | multi-choice | boolean | number`; the tool publishes this item schema to the model. The legacy `{ prompt, kind, schema }` form still works. A call that mixes the two is repaired when unambiguous (alias type, string options, missing id, top-level prompt for a lone question); otherwise it is rejected with a valid example.

Live (no durable store): the run waits, the stream shows `InteractionRequested`, and the answer becomes the tool result of the same run:

```ts
const agent = await ReactiveAgents.create()
  .withProvider("anthropic")
  .withReasoning()
  .withUserInteraction({ timeoutMs: 120_000 })      // optional: unanswered -> the model reads "did not answer"
  .build();

for await (const event of agent.runStream("Set up the deployment config")) {
  if (event._tag === "InteractionRequested") {
    // event.kind / event.prompt / event.schema describe the question
    void agent.respondToInteraction(event.runId, event.interactionId, { region: "us-east-1" });
  }
}
```

Durable: add `.withDurableRuns()` and the run pauses `awaiting-interaction` instead; answer from any process:

```ts
const agent = await ReactiveAgents.create()
  .withProvider("anthropic")
  .withReasoning({ defaultStrategy: "plan-execute-reflect", maxIterations: 20 })
  .withDurableRuns()
  .withUserInteraction()
  .withSystemPrompt(`
    When a decision genuinely needs the user (ambiguous requirements, a
    destructive choice), call request_user_input rather than guessing.
  `)
  .build();

const result = await agent.run("Set up the deployment config");

if (result.status === "awaiting-interaction" && result.pendingInteraction) {
  const { runId, interactionId } = result.pendingInteraction;
  // ...collect the human's answer...
  const final = await agent.respondToInteraction(runId, interactionId, { region: "us-east-1" });
}

// List runs awaiting a human response:
const waiting = await agent.listPendingInteractions();
```

### Runtime pause/resume/stop (kill switch)

For in-process control over an in-flight run — independent of the durable rails above:

```ts
const agent = await ReactiveAgents.create()
  .withProvider("anthropic")
  .withKillSwitch()  // enables pause/resume/stop/terminate on the agent
  .build();

const running = agent.run("Do a long task...");   // Promise<AgentResult>; control it through `agent`

await agent.pause();     // graceful pause (waits for current phase)
await agent.resume();    // resume from paused state
await agent.stop("cancelled by user");   // graceful stop
await agent.terminate("emergency shutdown"); // immediate termination
```

These methods live on the agent, not on the `run()` result. `agent.runStream()` returns a `RunHandle` with its own `pause()`, `resume()`, `stop()`, `terminate()`. Without `.withKillSwitch()` the agent methods reject with an error saying to enable it.

## Builder API reference

| Method | Notes |
|--------|-------|
| `.withDurableRuns(opts?)` | Required for durable approval/interaction pauses; persists run state to a store |
| `.withApprovalPolicy(cfg)` | Gate named tool calls, shell commands (`commands`), or a predicate behind human approval; `timeoutMs` denies an unanswered wait |
| `.withUserInteraction(opts?)` | Enable agent-initiated `request_user_input` (live wait, or a durable pause with `.withDurableRuns()`); `timeoutMs` bounds a live wait |
| `.withKillSwitch()` | In-process `agent.pause()` / `resume()` / `stop()` / `terminate()` |

### Runtime methods (durable HITL)

| Method | Notes |
|--------|-------|
| `agent.approveRun(runId, opts?)` | Approve a paused run and resume to completion |
| `agent.denyRun(runId, reason)` | Deny a paused run |
| `agent.listPendingApprovals()` | Runs currently awaiting approval |
| `agent.respondToInteraction(runId, interactionId, value)` | Answer an agent-initiated `request_user_input` and resume |
| `agent.listPendingInteractions()` | Runs currently awaiting a human response |

## Pitfalls

- `.withApprovalPolicy({ mode: "detach" })` does NOT need `.withDurableRuns()`: without it the run waits live in process (`runStream()` emits `ApprovalRequested` and stays open) until `approveRun`/`denyRun` or `run(task, { onApproval })` answers. Add `.withDurableRuns()` only when the answer comes from another process or must survive a restart
- With `mode: "detach"` + `.withDurableRuns()`, a gated run returns `status: "awaiting-approval"` and does NOT block — you must call `approveRun`/`denyRun` (or pass an `onApproval` callback) to finish it
- `mode: "block"` decides in code via `onApprove` (no person in the loop); with no `onApprove` every gated call is refused
- `.withUserInteraction()` does NOT need `.withDurableRuns()`: without it a question waits live. Without `timeoutMs` that wait lasts until answered, stopped or terminated; an unanswered question (timeout, `stop()`) reaches the model as "The user did not answer: <reason>" and the run continues
- Kill switch controls (`pause`, `resume`, `stop`, `terminate`) are no-ops without `.withKillSwitch()` — no error is thrown, calls are silently ignored
- `request_user_input` only fires if the model chooses to call it — reinforce in the system prompt when it should ask rather than guess
- `denyRun` requires a reason string; `approveRun` takes an optional `{ reason }`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.