Skip to content
Agent Graph

API Reference

Libraries

npm install git+ssh://git@github.com:stainless-sdks/agent-graph-typescript.git

API Overview

Graphs

A graph is one of your account’s live shares: the sessions and agents agent-graph watch-remote streams from a machine, kept on the site while it’s in use, and deleted after a week with no new events.

Retrieve a graph to see what it holds (retention), how big it is, and how its nodes stand (counts), now or as of any retained event.

List graphs
GET/graphs
Retrieve a graph
GET/graphs/{graph_id}

GraphsNodes

A node is a session (one run of a coding agent) or an agent it started. Nodes form trees:

session        claude-code:5f2c1e…            depth 0, parent_id null
├─ agent       claude-code:5f2c1e…/a3fd07…    depth 1
│  └─ agent    claude-code:5f2c1e…/b81c22…    depth 2
└─ agent       claude-code:5f2c1e…/c90d13…    depth 1

Every node says where it sits: parent_id, root_id (the top of its tree, following sessions that started other sessions), session_id (the session it runs in) and depth.

State. A node’s state is one of:

StateMeaning
workingDoing something.
input_requiredWaiting on a person: a permission prompt, a question, a plan to approve. attention says what’s asked.
idleA session whose turn is over, alive and waiting for its next prompt.
completedFinished.
failedFinished with an error.
canceledStopped before it finished.

Waiting on another node isn’t a state: a node can be working and blocked at once. blocked says what it’s waiting on, directly (on_ids) and in all (how many nodes, how many open tasks among them), and whether the waits form a cycle that can never finish. A working node with no events for 30 minutes, and nothing it’s waiting on, is stale: it may have hung or crashed.

List nodes
GET/graphs/{graph_id}/nodes
Search nodes
GET/graphs/{graph_id}/nodes/search
Retrieve a node
GET/graphs/{graph_id}/nodes/{node_id}

GraphsEvents

An event is one thing that happened in a graph. Events are immutable and ordered by id, which sorts by time.

Each event has the payload its agent tool reported, and changes: every node the event changed, and for each, the fields that changed, from what to what. A node’s derived fields count too: an agent being spawned changes its parent’s child_count, and every ancestor’s descendant_count.

List events starting_after the last one you saw to follow a graph cheaply, or with order=asc from any point to replay its history.

Event types

TypepayloadWhen
session.startedcwd?, source? (startup, resume, …), title?, link_method?A session starts or resumes.
session.endedreason?A session exits.
agent.spawnedagent_type?, purpose?, background?An agent starts.
agent.finishedstatus (completed, failed, canceled), summary?An agent stops.
statusstate, summary?, title?A node’s state or status line changes.
tasks.updateditems: [{id, text, active_text?, status}]A to-do tool sent its whole list, which replaces the node’s.
task.upsertedid, text?, active_text?, status?One task was created or changed.
task.deletedidA task was removed.
spawn.requestedcall_id, kind (agent, session), agent_type?, purpose?, backgroundA node asked for a child to start. Unless background, it’s blocked until the call returns.
spawn.returnedcall_id, child?, outcome?That call returned.
wait.startedwait_id, on (a provider node id), reason?A node blocked on another for some other reason.
wait.endedwait_id, outcome?That block cleared.
message.sentmessage_id, to, reply_to?, summary?, body?One node sent another a message.
activitytool, label?A tool call, when the share records them.

Ids inside payload are the provider’s own (as in provider_ref), exactly as the agent tool reported them; use node_id and changes for API ids. More types may be added: ignore those you don’t recognise.

List events
GET/graphs/{graph_id}/events
Retrieve an event
GET/graphs/{graph_id}/events/{event_id}