Agents in a Space

Start, follow, message and stop coding-agent runs inside a Space.

An agent run is a coding-agent CLI started in the Space with a prompt, detached from the call that started it.

Agent runs#

Methods of Space.

Space.agent_start#

Starts an agent CLI (claude-code, openai-codex, ...) with a prompt, as a detached spacesd process.

async def agent_start(self, agent: str, prompt: str, show: Optional[bool], options: Optional[SpaceAgentOptions]) -> AgentStartReport
ParameterTypeDefault
agentStringrequired
promptStringrequired
showOption<bool>required
optionsOption<SpaceAgentOptions>required

Returns AgentStartReport · Async · Raises CuaError

Space.agent_status#

A run's status with the last tail lines of output.

async def agent_status(self, run_id: str, tail: Optional[int]) -> AgentRunStatus
ParameterTypeDefault
run_idStringrequired
tailOption<u32>required

Returns AgentRunStatus · Async · Raises CuaError

Space.agent_events#

Normalized events after cursor (0: the start), as the agent_events JSON (events, cursor, caught_up, status).

async def agent_events(self, run_id: str, cursor: Optional[int], max: Optional[int]) -> str
ParameterTypeDefault
run_idStringrequired
cursorOption<u64>required
maxOption<u32>required

Returns String · Async · Raises CuaError

Space.agent_message#

Sends a follow-up message to a run.

async def agent_message(self, run_id: str, text: str, force: Optional[bool]) -> AgentActionReport
ParameterTypeDefault
run_idStringrequired
textStringrequired
forceOption<bool>required

Returns AgentActionReport · Async · Raises CuaError

Space.agent_interrupt#

Cancels the run's turn in flight; the session stays open.

async def agent_interrupt(self, run_id: str) -> AgentActionReport
ParameterTypeDefault
run_idStringrequired

Returns AgentActionReport · Async · Raises CuaError

Space.agent_list#

Every agent run in this Space.

async def agent_list(self) -> List[AgentRunStatus]

Returns Vec<AgentRunStatus> · Async · Raises CuaError

Space.agent_stop#

Stops a run.

async def agent_stop(self, run_id: str) -> AgentActionReport
ParameterTypeDefault
run_idStringrequired

Returns AgentActionReport · Async · Raises CuaError

Harnesses#

Methods of Spaces.

Spaces.agent_capabilities#

What every agent harness is and cannot do (agent_capabilities), as JSON.

async def agent_capabilities(self) -> str

Returns String · Async · Raises CuaError

AgentStartReport record#

Result of Space.agent_start.

Returned by Space.agent_start.

FieldTypeDefaultDescription
run_id / runIdStringRun id.
agentStringAgent.
spaceStringSpace.
process_tag / processTagStringspacesd process tag of the first turn.
notesVec<String>Preparation steps that could not be completed.
jsonStringThe whole report as JSON.

AgentRunStatus record#

One agent run's status.

Returned by Space.agent_list, Space.agent_status.

FieldTypeDefaultDescription
run_id / runIdStringRun id.
agentOption<String>Agent.
statusStringStatus (running, done, failed, ...).
reasonStringWhy.
phaseStringFiner grain: installing, working, waiting, exited, ...
result_text / resultTextOption<String>The last turn's final text (agent_status only).
accepts_message / acceptsMessageboolA follow-up sent now starts the next turn (the server's rule: idle, or a crashed or failed run it restarts; not mid-turn). Read this, never derive it from status.
output_tail / outputTailOption<String>Output tail.
jsonStringThe whole status as JSON.

AgentActionReport record#

Result of Space.agent_message / Space.agent_stop.

Returned by Space.agent_interrupt, Space.agent_message, Space.agent_stop.

FieldTypeDefaultDescription
run_id / runIdStringRun id.
okboolDelivered (message) or stopped (stop).
reasonStringWhy.
jsonStringThe whole report as JSON.

SpaceAgentOptions record#

Options for Space.agent_start beyond the harness and prompt.

FieldTypeDefaultDescription
env_from_host / envFromHostVec<String>[]Provider key variables forwarded from the Spaces host's environment.
envHashMap<String, String>[:]More environment for the agent, for example HERMES_HOME (stored 0600 in the run, redacted from its output; not for provider keys).
repoOption<String>None
branchOption<String>None
cwdOption<String>None
modelOption<String>None
base_url / baseUrlOption<String>NoneA custom model endpoint.
exit_when_idle / exitWhenIdleOption<bool>NoneStop (resumably) once the prompt is answered.
homeOption<String>NoneRun as this persistent agent: its home in the Cua Volume is restored first and saved after every turn (see Spaces.persistent_agent_send).