Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

13.2 KB
Raw Blame

Agent Commands

Manage AI agents: create, edit, delete, list, run, and check status.

Source: apps/cli/src/commands/agent.ts

lh agent list

List all agents.

lh agent list [-L <n>] [-k <keyword>] [--json [fields]]
Option Description Default
-L, --limit <n> Maximum items 30
-k, --keyword <keyword> Filter by keyword -
--json [fields] JSON output with optional field filter -

Table columns: ID, TITLE, DESCRIPTION, MODEL


lh agent view [agentId]

View agent configuration details. agentId may be omitted when -s, --slug is given instead.

lh agent view [agentId] [-s <slug>] [--json [fields]]

Displays: Title, description, visibility (workspace agents only), model, provider, system role, plugins, tools.


lh agent create

Create a new agent.

lh agent create [-t <title>] [-d <desc>] [-m <model>] [-p <provider>] [-s <role>] [--group <groupId>] [--visibility <private|public>] [--json [fields]]
Option Description Required
-t, --title <title> Agent title No
-d, --description <desc> Description No
-m, --model <model> Model ID No
-p, --provider <provider> Provider ID No
-s, --system-role <role> System prompt No
--group <groupId> Agent group ID No
--visibility <visibility> Who can see the agent in a workspace: private (only you) or public (workspace members). Omit to keep the server default No
--json [fields] Print the created agent as JSON, optionally selecting fields (e.g. --json id,visibility) No

The workspace comes from the current scope (LOBEHUB_WORKSPACE_ID or lh workspace use); --visibility only chooses who inside that scope can see the agent. An invalid value exits 1 before any request is sent.

Output: Without --json, the created agent ID, its session ID when there is one, the requested visibility, and the agent URL. With --json, an object { id, sessionId?, title, url, visibility, workspaceId }. visibility and workspaceId are read back from the server after creation, so they are the stored values (server default or folder-inherited included), not an echo of the flag. If that read-back fails, the agent still exists: id is printed, visibility and workspaceId are null, and a warning goes to stderr. Do not retry the create in that case.


lh agent connect [types...]

Connect external agent CLIs (Claude Code, Codex, Antigravity, OpenClaw, …) as agents bound to a device: the CLI form of the Web "Connect agent" wizard, creating the same agent config.

lh agent connect [types...] [--device <deviceId>] [--visibility <private|public>] [-n <name>] [-d <desc>] [--yes] [--json [fields]]
Option Description
types... Agent types to connect (e.g. antigravity, claude-code); omit to connect every one found
--device <deviceId> Bind to this device instead of this machine (see lh device list)
--visibility <visibility> Inside a workspace: private (default, only you) or public (workspace members)
-n, --name <name> Agent name; only with exactly one type
-d, --description <desc> Agent description; only with exactly one type
--yes Skip the confirmation prompt (required without an interactive terminal)
--json [fields] Print { created: [{ id, title, type, url, version? }], deviceId, skipped: [{ id, title, type }] }

The device defaults to this machine in the current scope's pool: its workspace device inside a workspace (only workspace devices qualify there), else its personal device. It must be connected (lh connect, or lh connect --workspace <id> for a workspace) and online. The device is scanned through the server, so a named type that is not installed there fails with the scan's reason. Types you already have an agent for on the device are skipped (teammates' agents on a shared workspace device do not count), so rerunning connects only what is missing. The scan checks the binary only: an agent CLI that needs sign-in (Antigravity, Codex, …) must be signed in on the device before its first run.


lh agent edit [agentId]

Update an existing agent. agentId may be omitted when --slug is given instead (note: unlike create/view, this flag has no -s short alias here because -s is used for --system-role). Only specified fields are updated.

lh agent edit [agentId] [--slug <slug>] [-t <title>] [-d <desc>] [-m <model>] [-p <provider>] [-s <role>] [--graph-file <path>] [--enable-graph] [--disable-graph] [--agency-config-file <path>] [--config-file <path>] [--json [fields]]
Option Description
--slug <slug> Agent slug, alternative to agentId
-t, --title <title> New title
-d, --description <desc> New description
-m, --model <model> New model ID
-p, --provider <provider> New provider ID
-s, --system-role <role> New system role prompt
--graph-file <path> AgentGraph JSON file
--enable-graph Enable graph runtime
--disable-graph Disable graph runtime
--agency-config-file <path> agencyConfig JSON, deep-merged into the agent (send null to clear a nested key)
--config-file <path> Agent config JSON for fields without a dedicated flag; deep-merged server-side, identity fields rejected
--json [fields] Output the updated agent as JSON, optionally selecting fields

lh agent delete <agentId>

Delete an agent.

lh agent delete <agentId> [--yes]

Requires confirmation unless --yes is provided.


lh agent duplicate <agentId>

Duplicate an existing agent.

lh agent duplicate <agentId> [-t <title>]
Option Description
-t, --title <title> Optional new title for the duplicate

Output: New agent ID.


lh agent run

Start an agent execution. Streams over the agent gateway WebSocket.

lh agent run [-a <id>] [-s <slug>] [-p <text>] [-t <id>] [--no-auto-start] [--device <target>] [--no-headless] [--tool <id>]... [--skill <id>]... [--json] [-v] [--replay <file>]
Option Description
-a, --agent-id <id> Agent ID to run
-s, --slug <slug> Agent slug (alternative to ID)
-p, --prompt <text> User prompt
-t, --topic-id <id> Reuse existing topic
--no-auto-start Don't auto-start the agent
--device <target> Target device ID, or local for the current connected device
--no-headless Wait for human approval on tool calls instead of auto-running them (default: headless)
--tool <id> Enable a tool for this run on top of the agent's own, like an @-mention (repeatable)
--skill <id> Load a skill for this run and the rest of its topic, like picking it in chat (repeatable)
--json Output full JSON event stream
-v, --verbose Show detailed tool call info
--replay <file> Replay events from saved JSON file (offline)

Streaming Behavior

Uses utils/agentStream.ts. The agent gateway WebSocket delivers real-time notifications; the authenticated aiAgent.getOperationStreamHistory API supplies the ordered event journal. JWT and API-key authentication are supported. Reconnects refresh credentials and retry with exponential backoff (up to six consecutive failures, capped at 15 seconds). A heartbeat watchdog detects half-open sockets. History reads also check for a lost terminal notification.

The journal is replayed in exclusive-cursor pages on connection and reconnect, so output is not duplicated or lost when the gateway buffer is trimmed or hibernated. JSON output remains one array. Missing/truncated/expired history is an unknown outcome (exit 3), never a successful recovery. Transport recovery does not restart the server-side run.

Self-hosted and local servers need a matching gateway configured with AGENT_GATEWAY_URL on both the server and CLI, and a matching server-side gateway service token. The gateway must trust the server's JWT signing key or support API-key verification against that server.

  1. Sends agent run request to backend, receiving an operationId
  2. Connects to the gateway WebSocket and streams events in real-time
  3. Displays: text chunks, tool call status, operation progress
  4. Shows final token usage and cost summary

Task start --follow, run --follow, and run --topics N use the same WebSocket transport. Each topic waits for completion before the next begins. A failed stream stops the sequence without sending a completion heartbeat or starting another topic. Full history recovery is available within the server stream's existing two-hour inactivity retention window (each publish renews it). Streams are no longer trimmed at 1,000 events. This is temporary Redis retention, not permanent archival storage; it increases Redis memory requirements. Existing pre-deploy streams with a trimmed prefix cannot be recovered.

Replay Mode

--replay <file> reads a saved JSON event stream for offline debugging without server connection.


lh agent status <operationId>

Check agent operation status.

lh agent status <operationId> [--json [fields]] [--history] [--history-limit <n>]
Option Description Default
--json [fields] JSON output -
--history Include step history false
--history-limit <n> Max history entries 10

Displays: Status (running/completed/failed), steps count, tokens used, cost, error info, timestamps.