Skip to main content

cloud_agents

Creates, updates, deletes, gets or lists a cloud_agents resource.

Overview​

Namecloud_agents
TypeResource
Idrailway.agents.cloud_agents

Fields​

The following fields are returned by SELECT queries:

One CloudAgent row. A persistent cloud agent for running coding harnesses.

NameDatatypeDescription
idstring
namestring
console_target_idstringTarget ID for console or command execution. Null while unavailable.
environment_idstring
project_idstring
agent_ws_urlstringWebSocket endpoint of the in-VM harness gate, for the dashboard chat. Survives sleep: the domain is stable across sleep and wake. Prefers the machine observation; when that carries no gate domain it falls back to the domain network-cp actively serves, so an agent whose observation lagged still offers chat. Null on agents created before the gate existed, or asleep/absent machines.
created_atstring (date-time)
domainstringThe agent machine's public HTTP domain (port 8080) — the live preview. Prefers the observation (falling back to the first declared domain when 8080 was never requested); when the observation carries no domains it falls back to the domain network-cp actively serves on 8080, so a preview shows even when the observation lagged. Returns null while the machine sleeps.
domainsarrayEvery public domain on the agent's machine, one per port, in the order the machine declared them.
projectobjectProject object
regionstringRegion the agent's machine runs in. Null briefly after creation, before the machine has been placed.
sessionsarrayLive coding-agent sessions, one entry per session. Retained for 24h after the last report, so a sleeping agent still shows what it was last doing.
sourceobjectRepo this agent's workspace was created from. Null for agents created without a source.
statusstring (CRASHED, DELETING, FAILED, RUNNING, SLEEPING, STARTING)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectenvironment_id, idA cloud agent by ID, within an environment. Null when the agent belongs to another one, so a caller cannot render an agent it has switched away from. Backed by the Railway GraphQL query cloudAgent.
listselectenvironment_idmineCloud agents in an environment. Backed by the Railway GraphQL query cloudAgents.
list_mineselectCloud agents you own, across every project and environment you can reach. Answers "where are my agents" in one request; cloudAgents needs one call per environment. Machine fields (status, domain, domains) read the last observed state in batched queries, so selecting them across many environments is fine. Backed by the Railway GraphQL query myCloudAgents.
createinsertenvironment_idCreate a cloud agent. Backed by the Railway GraphQL mutation cloudAgentCreate.
deletedeleteidDelete a cloud agent. Backed by the Railway GraphQL mutation cloudAgentDelete.
deployexecidpath, regions, service_nameBuild the agent's code inside its own VM and deploy it. Creates the named service (default: the agent's name) or reuses it. Needs an agent booted with the builder. Backed by the Railway GraphQL mutation cloudAgentDeploy.
forkexecidname, variablesDuplicate a running cloud agent. Backed by the Railway GraphQL mutation cloudAgentFork.
harness_tokenexecenvironment_id, idMint a short-lived (5m) JWT for the agent's harness WebSocket (see agentWsUrl). The in-VM gate verifies signature/exp/aud and pins it to this agent. Mint one per dial; the token only has to survive the upgrade. Backed by the Railway GraphQL mutation cloudAgentHarnessToken.
sleepexecidSleep a running cloud agent, keeping its volume. Processes on the machine are terminated; waking re-runs its entrypoint. Backed by the Railway GraphQL mutation cloudAgentSleep.
wakeexecidWake a sleeping cloud agent. Backed by the Railway GraphQL mutation cloudAgentWake.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
environment_idstring
idstring
minebooleanReturn only the agents that belong to you. By default every agent in the environment is returned, including your teammates'.
namestring
pathstring
regionsobjectReplicas per region, e.g. { "us-west2": 3 }. Saved on the service; omit to keep its current regions.
service_namestring
variablesobject

SELECT examples​

A cloud agent by ID, within an environment. Null when the agent belongs to another one, so a caller cannot render an agent it has switched away from. Backed by the Railway GraphQL query cloudAgent.

SELECT
id,
name,
console_target_id,
environment_id,
project_id,
agent_ws_url,
created_at,
domain,
domains,
project,
region,
sessions,
source,
status
FROM railway.agents.cloud_agents
WHERE environment_id = '{{ environment_id }}' -- required
AND id = '{{ id }}' -- required
;

INSERT examples​

Create a cloud agent. Backed by the Railway GraphQL mutation cloudAgentCreate.

INSERT INTO railway.agents.cloud_agents (
cloud_agent_checkpoint_id,
code_endpoint,
environment_id,
name,
region,
source,
variables
)
SELECT
'{{ cloud_agent_checkpoint_id }}',
'{{ code_endpoint }}',
'{{ environment_id }}' /* required */,
'{{ name }}',
'{{ region }}',
'{{ source }}',
'{{ variables }}'
RETURNING
id,
name,
console_target_id,
environment_id,
project_id,
agent_ws_url,
created_at,
domain,
domains,
project,
region,
sessions,
source,
status
;

DELETE examples​

Delete a cloud agent. Backed by the Railway GraphQL mutation cloudAgentDelete.

DELETE FROM railway.agents.cloud_agents
WHERE
id = '{{ id }}' --required
;

Lifecycle Methods​

Build the agent's code inside its own VM and deploy it. Creates the named service (default: the agent's name) or reuses it. Needs an agent booted with the builder. Backed by the Railway GraphQL mutation cloudAgentDeploy.

EXEC railway.agents.cloud_agents.deploy
@id='{{ id }}', --required
@path='{{ path }}',
@regions='{{ regions }}',
@service_name='{{ service_name }}'
;