Update sessions

Updates a session's surface-owned truth: its status, its title, the run-target it is dispatched to, and the product it built plus whether that build's story is public.

PATCH /v1/agent/sessions/{id}

Addresshttps://api.hanzo.ai/v1/agent/sessions/{id}
MethodPATCH
Operationpatch_agent_sessions_by_id
AuthAuthorization: Bearer $HANZO_API_KEY

Updates a session's surface-owned truth: its status, its title, the run-target it is dispatched to, and the product it built plus whether that build's story is public. A FINISHED session stays finished — reopening a done/error run would fabricate liveness — and publishing is refused unless the session names the project it built, because the public build route is keyed on (org, project).

Request

9 fields, body application/json (required).

FieldInTypeRequiredDescription
idpathstringyesID is the session to update, from the path.
cwdbodystring—Cwd is where the session is working NOW.
idbodystring—ID is the session to update, from the path.
projectbodystring—Project tags the product this session built; Published is the author's decision to let anyone read the story (provenance.go).
publishedbodyboolean—Published opens the session's story to the public build route; false withdraws it, and withdrawing is always allowed.
statusbodystring—Status moves the session to running, paused, done or error.
targetbodystring—Target re-dispatches a session to a run-target (the #48 association).
terminalbodystring—Terminal publishes (or, with "", withdraws) the URL this session's live terminal can be watched at.
titlebodystring—Title rewrites the human line, up to 512 characters — usually because the work turned out to be something other than what it was opened as.

Response

StatusBodyMeaning
200agent.sessionViewok
defaultproblem-detailsrefused

200 body — 45 fields.

FieldInTypeAlwaysDescription
accountbodystring—Account is which subscription or API account under that provider served it.
actorbodystring—Actor is WHO this session belongs to, as "org/sub" — the same identity a run is billed under.
agentbodystring—Agent is the label the surface running this session calls itself by ("hanzo-dev"), up to 128 characters.
basebodystring—Base is the branch the run started from.
branchbodystring—Branch is the branch the run pushes its work to, and the only one it may write.
childrenbodyinteger (int64)—Children is the DIRECT fan-out — how many sessions name this one as parent — and not the size of the subtree.
createdAtbodystring—CreatedAt is when the row was written, same format.
cwdbodystring—Cwd is the directory the session is working in NOW, not the one it started in: a linked shell moves around, and a card showing where hanzo link was run answers "which work is this" with something that was true once.
endedAtbodystring—EndedAt is when it reached done or error, same format.
environmentbodystring—Environment is where the run executes: "sandbox" for a Hanzo sandbox, or the id of the org's machine it was routed to (the same id Target carries).
eventsbodyinteger (int64)—Events is how many turns the session's log holds, counted at read time.
hostbodystring—Execution context (mission-control): the machine/repo/cwd a card shows and the run-target a session is dispatched to.
idbodystring—ID is the session's handle, minted here as "sess_" + 32 hex characters.
kindbodystring—Kind is what sort of run this session is the view of — "coding" for a coding run.
lastEventbodyagent.lastEventView—
lastEvent.actorbodystring—Actor is who produced the turn, defaulted to the calling principal when the writer named nobody.
lastEvent.atbodystring—At is when the turn was recorded, RFC 3339 in UTC to the second.
lastEvent.kindbodystring—Kind is what the turn was, from the log's closed six: message, tool-call, spawn, log, status, control.
lastEvent.previewbodystring—Preview is the first 240 bytes of the event's payload, cut without regard for the JSON inside it — it is a string to SHOW, never a value to parse.
lastEvent.seqbodyinteger (int64)—Seq is that event's position in the session's log — monotonic from 1, per session.
modebodystring—Mode is what the run may do to its repository: "build" edits, commits and pushes its branch; "plan" reads and answers with a plan, writing nothing.
orgbodystring—Org is the caller's OWN tenant, echoed so a client can build the public build URL (/builds/:org/:project) without a second call or a guess.
parentSessionIdbodystring—ParentSessionID is the session that spawned this one, making this a subagent of it.
prbodystring—PR is the address of the pull request the run proposed.
progressbodyagent.sessionProgress—
progress.activitybodystring—Activity is the one line saying what the run is doing right now ("running the reaper's tests"), up to 120 characters, in the model's words.
progress.atbodystring—At is when this was determined, RFC 3339 in UTC to the second.
progress.estimatedbodyboolean—Estimated says a MODEL produced this, from the run's transcript, and it may be wrong.
progress.pctbodyinteger (int64)—Pct is how much of the run is done, 0 to 100.
progress.phasebodystring—Phase is what shape the run is in: running, blocked, done, error, or unknown when nothing has estimated it yet.
projectbodystring—The readable build: the product this session built and whether its story is public (provenance.go).
providerbodystring—Provider is the linked AI account's provider (claude | codex | hanzo | …) that served this run.
publishedbodyboolean—Published is the author's decision to let anyone read this session's story at the public build route.
repobodystring—Repo is the code the session is working on, as the surface reported it.
roombodystring—Room is the collaborative room this run was started in (HIP-0523), empty when it came from anywhere else — a CLI, a schedule, an API call.
rootSessionIdbodystring—RootSessionID is the top of this session's tree, inherited from the parent and shared by every node in one flow.
sandboxbodystring—Sandbox is the id of the sandbox the run works in ("m_" and 24 hex), the handle its terminal and its screen are opened with (/v1/sandbox/{id}/terminal, /screen).
startedAtbodystring—StartedAt is when the session opened, RFC 3339 in UTC to the second.
statusbodystring—Status is one of exactly four: running, paused, done, error.
targetbodystring—Target is the registered run-target this session is dispatched to — a machine the org claimed, resolved same-org when it was set, so it can never point at another tenant's computer.
taskRunIdbodystring—TaskRunID is that workflow's particular run.
taskWorkflowIdbodystring—TaskWorkflowID is the hanzoai/tasks durable workflow that actually EXECUTES this session — this registry is the view, control and stream layer over it.
terminalbodystring—Terminal is where this session can be WATCHED — the URL the machine published for its live terminal.
titlebodystring—Title is the human line a card shows ("ship the landing page"), up to 512 characters.
updatedAtbodystring—UpdatedAt is the session's last-activity clock, same format.

Failure carries the platform error shape — see Errors.

Examples

hanzo agent sessions update <id>
import { Configuration, AgentApi } from 'hanzoai';

const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.patchAgentSessionsById({ id: 'id', cwd: "<cwd>", id: "<id>" });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).patch_agent_sessions_by_id(id='id', cwd="<cwd>", id="<id>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.AgentAPI.PatchAgentSessionsById(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, agent_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = agent_api::patch_agent_sessions_by_id(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new AgentApi(client).patchAgentSessionsById();
curl -X PATCH https://api.hanzo.ai/v1/agent/sessions/<id> \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "cwd": "<cwd>",
       "id": "<id>"
     }'

MCP reaches agent through the agent tool, which names its 38 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_agents"
         }
       }
     }'

Agent API · All Hanzo APIs · Interactive reference

Was this page useful?