Skip to content
Development
Agent

amp

Research notes on Sourcegraph Amp's configuration, credential discovery, and runtime behavior.

From plugin
agents
1.6k4 skills4 agents2 commands1 MCP

Agent definition

amp.md

Amp Research

Research notes on Sourcegraph Amp's configuration, credential discovery, and runtime behavior.

Overview

  • **Provider**: Anthropic (via Sourcegraph, proxied through ampcode.com)
  • **Execution Method**: CLI subprocess (`amp` command)
  • **Session Persistence**: Session ID (string)
  • **SDK**: `@sourcegraph/amp-sdk` (closed source)
  • **Binary**: Bun-bundled JS application (ELF wrapping Bun runtime + embedded JS)
  • **Binary Location**: `/usr/local/bin/amp`
  • **Backend**: `https://ampcode.com/` (server-side proxy for all LLM requests)

CLI Usage

Interactive Mode

amp "your prompt here"
amp --model claude-sonnet-4 "your prompt"

Non-Interactive Mode

amp --print --output-format stream-json "your prompt"
amp --print --output-format stream-json --dangerously-skip-permissions "prompt"
amp --continue SESSION_ID "follow up"

Key CLI Flags

| Flag | Description | |------|-------------| | `--print` | Output mode (non-interactive) | | `--output-format stream-json` | JSONL streaming output | | `--dangerously-skip-permissions` | Skip permission prompts | | `--continue SESSION_ID` | Resume existing session | | `--model MODEL` | Specify model | | `--toolbox TOOLBOX` | Toolbox configuration |

Credential Discovery

Priority Order

1. Environment variable: `ANTHROPIC_API_KEY` 2. Sourcegraph authentication 3. Claude Code credentials (shared)

Config File Locations

| Path | Description | |------|-------------| | `~/.amp/config.json` | Primary config | | `~/.claude/.credentials.json` | Shared with Claude Code |

Amp can use Claude Code's OAuth credentials as fallback.

Streaming Response Format

Amp outputs newline-delimited JSON events:

{"type": "system", "subtype": "init", "session_id": "...", "tools": [...]}
{"type": "assistant", "message": {...}, "session_id": "..."}
{"type": "user", "message": {...}, "session_id": "..."}
{"type": "result", "subtype": "success", "result": "...", "session_id": "..."}

Event Types

| Type | Description | |------|-------------| | `system` | System initialization with tools list | | `assistant` | Assistant message with content blocks | | `user` | User message (tool results) | | `result` | Final result with session ID |

Content Block Types

type ContentBlock =
  | { type: "text"; text: string }
  | { type: "tool_use"; id: string; name: string; input: Record<string, unknown> }
  | { type: "thinking"; thinking: string }
  | { type: "redacted_thinking"; data: string };

Response Schema

interface AmpResultMessage {
  type: "result";
  subtype: "success";
  duration_ms: number;
  is_error: boolean;
  num_turns: number;
  result: string;
  session_id: string;
}

Session Management

  • Session ID captured from streaming events
  • Use `--continue SESSION_ID` to resume
  • Sessions stored internally by Amp CLI

Agent Modes vs Permission Modes

Permission Modes (Declarative Rules)

Amp uses declarative permission rules configured before execution:

interface PermissionRule {
  tool: string;  // Glob pattern: "Bash", "mcp__playwright__*"
  matches?: { [argumentName: string]: string | string[] | boolean };
  action: "allow" | "reject" | "ask" | "delegate";
  context?: "thread" | "subagent";
}

| Action | Behavior | |--------|----------| | `allow` | Automatically permit | | `reject` | Automatically deny | | `ask` | Prompt user (CLI handles internally) | | `delegate` | Delegate to subagent context |

Example Rules

const permissions: PermissionRule[] = [
  { tool: "Read", action: "allow" },
  { tool: "Bash", matches: { command: "git *" }, action: "allow" },
  { tool: "Write", action: "ask" },
  { tool: "mcp__*", action: "reject" }
];

Agent Modes

No documented agent mode concept. Behavior controlled via:

  • `--toolbox` flag for different tool configurations
  • Permission rules for feature coverage restrictions

Bypass All Permissions

amp --dangerously-skip-permissions "prompt"

Or via SDK:

execute(prompt, { dangerouslyAllowAll: true });

Human-in-the-Loop

No Interactive HITL API

While permission rules support `"ask"` action, Amp does not expose an SDK-level API for programmatically responding to permission requests. The CLI handles user interaction internally.

For universal API integration, Amp should be run with:

  • Pre-configured permission rules, or
  • `dangerouslyAllowAll: true` to bypass

SDK Usage

import { execute, type AmpOptions } from '@sourcegraph/amp-sdk';

interface AmpOptions {
  cwd?: string;
  dangerouslyAllowAll?: boolean;
  toolbox?: string;
  mcpConfig?: MCPConfig;
  permissions?: PermissionRule[];
  continue?: boolean | string;
}

const result = await execute(prompt, options);

Installation

# Get latest version
VERSION=$(curl -s https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt)

# Linux x64
curl -fsSL "https://storage.googleapis.com/amp-public-assets-prod-0/cli/${VERSION}/amp-linux-x64" \
  -o /usr/local/bin/amp && chmod +x /usr/local/bin/amp

# Linux ARM64
curl -fsSL "https://storage.googleapis.com/amp-public-assets-prod-0/cli/${VERSION}/amp-linux-arm64" \
  -o /usr/local/bin/amp && chmod +x /usr/local/bin/amp

# macOS ARM64
curl -fsSL "https://storage.googleapis.com/amp-public-assets-prod-0/cli/${VERSION}/amp-darwin-arm64" \
  -o /usr/local/bin/amp && chmod +x /usr/local/bin/amp

# macOS x64
curl -fsSL "https://storage.googleapis.com/amp-public-assets-prod-0/cli/${VERSION}/amp-darwin-x64" \
  -o /usr/local/bin/amp && chmod +x /usr/local/bin/amp

Timeout

  • Default timeout: 5 minutes (300,000 ms)
  • Process killed with `SIGTERM` on timeout

Model Discovery

**No model discovery mechanism exists.** Amp uses a server-side proxy architecture where model selection is abstracted behind "modes".

Architecture (Reverse Engineered)

Amp is **NOT a Go binary** as previously thought — it

Read more
@rivet-dev
Ships withagents

Agent infrastructure from Rivet. Join us on Discord.

1.6k4 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
1.6k
Star history of rivet-dev/sandbox-agent on GitHub, a chart by star-history.com

Other agents on agents.

codex

codex

Agent

Research notes on OpenAI Codex's configuration, credential discovery, and runtime behavior based on agent-jj implementation.

@rivet-dev@rivet-devInstall Agent
openclaw

openclaw

Agent

Research notes on OpenClaw's architecture, API, and automation patterns for integration with sandbox-agent.

@rivet-dev@rivet-devInstall Agent
opencode

opencode

Agent

Research notes on OpenCode's configuration, credential discovery, and runtime behavior based on agent-jj implementation.

@rivet-dev@rivet-devInstall Agent

More agents from other plugins.

a11y-architect
Auto-invoked

a11y-architect

Agent

Accessibility Architect specializing in WCAG 2.2 compliance for Web and Native platforms. Use PROACTIVELY when designing UI…

ecc12d293k
@affaan-m@affaan-mInstall Agent
analyze-pass-impact

analyze-pass-impact

Agent

Analyzes how a specific topic affects a group of compiler passes. Used by the /plan-update skill to parallelize research across…

react1d252k
@facebook@facebookInstall Agent
orchestrator

orchestrator

Agent

- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as…

codextoday135k
@openai@openaiInstall Agent
cavecrew-builder

cavecrew-builder

Agent

Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard…

caveman2d119k
@juliusbrussee@juliusbrusseeInstall Agent

Questions about amp.

Which coding agents can use amp?
amp installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.