Sessions

Resuming

Reopen a session with its identifier. On the device that ran it you get everything back; from anywhere else, the conversation without what the tools returned.

agents.get(id)complete on the devicepartial elsewhere
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Reopening

const pc = await api.storage.get();
const agent = api.agents.get("6704f1c2a9b3d4e5f6a7b8c9", { machine: pc });

await agent.run({ inputs: "Carry on." });
pc = api.storage.get()
agent = api.agents.get("6704f1c2a9b3d4e5f6a7b8c9", machine=pc)

agent.run(inputs="Carry on.")

The model comes from the session, so it need not be repeated. Options you pass — mode, budget, tools, callbacks — apply to this run; they are not stored with the session.

The two ways it comes back

Reopened onWhat returns
The device that ran itEverything: the messages, the tool calls and their results, the todo list, the compacted state.
Another deviceThe messages, and the record of which tools were used — not what they returned.

The second case is still useful: the model has the conversation and knows what was done. It will read a file again if it needs its contents, which costs a tool call and no accuracy.

Where it looks

  • The device journal first — it is complete, and it is local.
  • Failing that, the account's record of the session.
  • Failing that, the history you passed to run().

A compacted session resumes from the summary

If the session was compacted, the journal holds the compacted state and that is what comes back — the whole earlier conversation is a summary, as it was when the run ended. Checkpoints before the summary are no longer offered.

The machine is still required

A session does not carry its workspace

Reopening on a different machine gives you the conversation, not the files it refers to. Paths in the history point at a workspace that may hold something else entirely — which is the honest behaviour, but it is yours to account for.

Reading it without running it

const agent = api.agents.get(id, { machine: pc });
const messages = await agent.getHistory();

for (const m of messages) {
  console.log(m.role, m.parts?.[0]?.content);
  for (const call of m.toolCalls || []) console.log("  ", call.name, call.target, call.credits);
}
agent = api.agents.get(session_id, machine=pc)
messages = agent.get_history()

for m in messages:
    print(m["role"], (m["content"] or "")[:80])
    if m["role"] == "tool":
        print("  ", m["name"])