amp
Research notes on Sourcegraph Amp's configuration, credential discovery, and runtime behavior.
How it fires
How this agent gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Research notes on Sourcegraph Amp's configuration, credential discovery, and runtime behavior.
Agent definition
amp.mdAmp 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/ampTimeout
- 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
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/ampTimeout
- 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
Run Coding Agents in Sandboxes. Control Them Over HTTP. Supports Claude Code, Codex, OpenCode, and Amp.
Repo: rivet-dev/sandbox-agent
Other agents on sandbox-agent.
- codex
Research notes on OpenAI Codex's configuration, credential discovery, and runtime behavior based on agent-jj implementation.
Open agent - openclaw
Research notes on OpenClaw's architecture, API, and automation patterns for integration with sandbox-agent.
Open agent - opencode
Research notes on OpenCode's configuration, credential discovery, and runtime behavior based on agent-jj implementation.
Open agent

