Agentuity Coder is the session layer around coding agents. It runs coding agents in cloud sandboxes, gives each run a durable Hub, and lets humans, apps, and other agents attach to the same stream from the SDK, API, CLI/TUI, or web app.
Use Coder when coding work needs to survive the terminal that started it: start a session from an app or internal tool, inspect it later, resume it after a disconnect, or let teammates watch the same session.
Use the @agentuity/coder package to manage sessions from any Node.js or Bun application without the full runtime.
When to Use Coder
| Approach | Best For |
|---|---|
| Coder sessions | Coding work that should run in a cloud sandbox and remain available as a session you can inspect, resume, share, or drive from another app |
| Claude Code/Cowork plugin | Agentuity skills inside Claude Code and Cowork for SDK work, cloud services, and deploys. It does not manage Coder sessions. |
| OpenCode plugin | Agentuity multi-agent workflows inside OpenCode with specialized agents, slash commands, and headless runs. It is separate from managed Coder session lifecycle. |
| Sandbox service | One-off isolated execution when you do not need Coder session state, replay, or reconnect flows |
Use Coder when the unit of work is a shared session with history, lifecycle, and reconnect semantics, not just a sandbox process.
Managing Sessions
| Method | Best For |
|---|---|
SDK (CoderClient) | Programmatic session management from your app, automation, internal tooling, or another agent |
| REST API | Creating or inspecting sessions from services that do not use the SDK |
CLI/TUI (agentuity coder) | Starting, attaching to, and driving sessions from the terminal through Pi |
| Web App | Inspecting session state, replay, and history from a browser |
Coder has HTTP endpoints, but no single static base URL. If neither url nor AGENTUITY_CODER_URL is set, clients call the Agentuity API to discover your org's Hub address, then route session and workspace requests to that Hub. @agentuity/coder and agentuity coder handle discovery, auth, and routing for you.
You can validate CoderClient without deploying an app. If discovery works but session calls fail at the org level, Coder is probably not enabled for that org yet.
How It Works
A Coder session has three components:
- Hub: Real-time broadcast server where participants (humans, apps, agents) subscribe to the same event stream; also manages session lifecycle and tools
- Agent: An AI coding agent that connects to the Hub and executes tasks
- Sandbox: An isolated cloud environment where the agent writes, builds, and tests code
Sessions support multiple participants: the primary agent, sub-agents that split work, teammates in the web app, a terminal TUI, SDK/API clients, and observers that stream the session in real time.
Agents and Skills
Coder has a few different layers that are easy to mix up:
- Built-in agents are the built-in Coder team roles like
builder,reviewer, andscout - System skills are Hub-managed skills that the platform injects automatically
- Saved skills and skill buckets are user-managed selections you attach to sessions or workspaces
Use enabledAgents to choose the agent roster for a session or workspace. Use defaultAgent when you want routed work to prefer a specific agent.
Workspaces bundle the setup a coding session needs: repositories, saved skills, skill buckets, and agent selections. Custom agents let you package reusable domain knowledge, tools, service access, and companion agents. Use createAgentBuilderSession() when you want Agent Builder to help create or update a reusable custom agent programmatically.
Reading Session State
When you inspect a session from the SDK or CLI, these fields do most of the work:
| Field | What It Tells You |
|---|---|
status | The current service-provided lifecycle state, such as creating, provisioning, active, or paused |
bucket | The broader lifecycle bucket: running, paused, provisioning, or history |
runtimeAvailable | Whether the runtime is currently available for live interaction |
controlAvailable | Whether a controller client can actively drive the session |
wakeAvailable | Whether the session can be resumed or woken back up |
historyOnly | Whether the session is no longer live and should be treated as replay-only |
liveExpected | Whether the Hub still expects a live runtime to come online |
In practice:
historyOnly: trueusually means “switch to replay or a read-only session view”runtimeAvailable: trueusually means “the session is live enough to attach to”wakeAvailable: trueusually means “the session is not live now, but it may still be resumable”- fresh sessions often have little or no replay, event history, or participant data yet
Which Read Method to Use
| Need | Start Here |
|---|---|
| One session's current state | getSession() |
| A dashboard or picker of many sessions | listSessions() |
| Running or resumable sessions that clients can attach to | listConnectableSessions() |
| Wake a paused session before attaching | prepareSessionForRemoteAttach() |
| Catch a late-joining client up to current state | getReplay() |
| Build a structured timeline or audit view | listEventHistory() |
| See who is currently attached | listParticipants() |
| Watch the live session feed | subscribeToCoderHub() |
SDK Usage
Install the standalone package:
bun add @agentuity/coderIf you want the cleanest first SDK integration, start with Managing Coder Sessions with the SDK. For the rest of the runnable Coder examples, see the Coder cookbook section, including how to branch into Loop-Mode Sessions, Attach Skills, Use Workspaces, and more.
Creating and Listing Sessions
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient();
// Create a new session
const session = await client.createSession({
task: 'Implement OAuth login with GitHub provider',
workflowMode: 'standard',
tags: ['auth', 'feature'],
});
console.log(`Session created: ${session.sessionId}`);
// List active sessions
const { sessions } = await client.listSessions({ limit: 10 });
for (const s of sessions) {
console.log(`${s.sessionId}: ${s.label} (${s.status})`);
}Session Operations
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient();
// Get session details
const session = await client.getSession('codesess_abc123');
// Update a session
await client.updateSession('codesess_abc123', {
tags: ['auth', 'feature', 'phase-2'],
visibility: 'organization',
});
// Archive a completed session so its history stays available for replay and inspection
await client.archiveSession('codesess_abc123');
// Resume a paused session (wakes the sandbox)
await client.resumeSession('codesess_abc123');
// Permanently delete a session
await client.deleteSession('codesess_abc123');Session Data and Replay
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient();
const sessionId = 'codesess_abc123';
// Get the replay payload a late-joining client uses to catch up
const replay = await client.getReplay(sessionId);
// List participants in a session
const participants = await client.listParticipants(sessionId);
// Get event history
const events = await client.listEventHistory(sessionId, { limit: 50 });
// Check loop state (for autonomous sessions)
const loopState = await client.getLoopState(sessionId);Workspaces and Skills
Workspaces group repositories, skills, and agent selections into reusable configurations that can be attached to sessions.
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient();
// Create a workspace
const workspace = await client.createWorkspace({
name: 'Auth System',
description: 'OAuth and session management',
enabledAgents: ['builder', 'reviewer'],
});
// Save a reusable skill
const skill = await client.saveSkill({
repo: 'my-org/my-skills',
skillId: 'code-review',
name: 'code-review',
description: 'Review code for security issues',
content: 'Review the changes for OWASP top 10 vulnerabilities...',
});
// List saved skills
const { skills } = await client.listSavedSkills();Client Configuration
The client picks one of two modes based on what you provide.
Discovery mode (recommended). Omit url and AGENTUITY_CODER_URL; the client calls the Agentuity API to resolve your org's Hub. region is only consulted in this mode.
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient({
apiKey: 'agentuity_sk_...', // Override AGENTUITY_SDK_KEY
region: 'usc', // Region used when discovering the Hub
orgId: 'org_...', // Organization scope
});Explicit mode. Set url (or AGENTUITY_CODER_URL) to a known Hub. Discovery is skipped, and region has no effect.
import { CoderClient } from '@agentuity/coder';
const client = new CoderClient({
url: 'https://coder.example.com', // Explicit Hub URL, skips discovery
apiKey: 'agentuity_sk_...',
orgId: 'org_...',
});The client resolves the Hub URL in this order:
options.url(explicit)AGENTUITY_CODER_URLenvironment variable- Auto-discovery via the Agentuity API
Most apps only need the API key. Set AGENTUITY_SDK_KEY and let the client discover the rest.
CLI Usage
# Open the interactive terminal session
agentuity coder tui
# Create a managed session without attaching
agentuity coder create "Build an auth system"
# Create a managed session and attach immediately
agentuity coder create "Build an auth system" --connect
# Open the interactive terminal session against an existing remote session
agentuity coder tui --remote codesess_abc123
# List active sessions
agentuity coder list
# Inspect a session
agentuity coder get codesess_abc123See Coder CLI Commands for the full command reference.
Session Modes
Running agentuity coder tui with no extra flags launches the interactive terminal session. Using agentuity coder tui --sandbox <task> creates a cloud sandbox session and attaches to it. Using agentuity coder tui --remote <session_id> attaches to an existing connectable session, and bare --remote opens the session picker.
| Mode | Description |
|---|---|
tui | Interactive agent in your local terminal |
sandbox | Agent runs in a cloud sandbox; observe via CLI or web |
remote | Attach to an existing connectable cloud session |
Session Lifecycle
status is a detailed string from the Coder service. For UI grouping, use the SDK's bucket field.
| Bucket | Description |
|---|---|
provisioning | Session is being created or waiting for its runtime to come online |
running | Runtime is live or expected to be live |
paused | Runtime is offline, but the session may still be wakeable |
history | Session is replay-only; use replay or event history instead of live attach |
Connecting via Plugins
The Claude Code and OpenCode plugins integrate with the Coder ecosystem:
- Claude Code/Cowork: The Agentuity plugin adds auto-activated Agentuity skills to Claude Code and Cowork. Use it when you want help deploying apps, managing cloud services, or building with the SDK from that editor workflow. It is not the API for creating or inspecting Coder sessions.
- OpenCode: The OpenCode plugin adds Agentuity-aware agents, slash commands, and dashboard tooling to OpenCode. Use it when you want an editor-based multi-agent workflow rather than a managed Coder session.
Next Steps
- Managing Coder Sessions with the SDK: Core SDK flow for create, read, archive, and delete operations
- Choosing Built-In Agents for a Coder Session: Choose the built-in roster for a session
- Attaching Skills to a Coder Session: Attach saved skills and skill buckets from your library
- CoderClient Reference: Full method reference for
@agentuity/coder - Coder CLI Commands: Full command reference