What a session runs with
A session's model, thinking level and turn limit, and which of the agent's tools it may use and which
of its calls wait for approval, are chosen per session and stored with it, so they hold after a
restart. createSession() sets them, session.configure() changes any of them in one commit (a field
left out keeps its value, null puts back the agent's), and session.settings() reads them back:
// A session that may only read, asks before every call of it, and takes at most five tool rounds a run.
const { id } = await instance.createSession({ tools: ["read_note"], requiresApproval: ["read"], maxTurns: 5 });
// Later: a bigger model that thinks harder, every tool but delete_note, and write-tier calls run without asking.
await instance.session(id).configure({
model: { provider: "anthropic", modelId: "claude-opus-5" },
thinkingLevel: "high",
tools: { remove: ["delete_note"] },
requiresApproval: { remove: ["write"] },
});modelis pi'sModelRef;nullputs back the model a new session gets, the agent's, else the runtime'sdefaultModel, and rejects with aTypeErrorwhen there is neither.thinkingLevelis pi-ai'sModelThinkingLevel;nullputs back pi-durable's default. A change to either applies from the run's next model request.maxTurnsbounds the tool rounds of one run: the round that reaches it runs its tools, then the run ends without an answer (run:endwithreason: "error",code: "turn_limit"anderror: "1 turn"or"N turns"), andcontinuecarries it on. It is an integer, 1 or more; anything else rejects with pi-durable'sRangeErrorand changes nothing, the other fields of the call included.nulltakes the limit away.toolsis a list of the agent's tool names, exactly those, or{ remove }: every one but those. The model is offered only the session's tools, and a call of another one ends with an error result without running. It chooses among the agent's own tools: the tools of app extensions stay on whatever it says. It is pi-durable's per-conversation tool selection, which the runtime stores as the agent's tools to remove; a change applies from the run's next model request.requiresApprovalis a list of tiers, exactly the calls of those wait, or{ add, remove }: the agent's policy withaddtiers gated as well andremovetiers not. It applies to every call that reaches the gate after the change. A call already waiting keeps waiting, and its decision decides it whatever the rule says by then: a declined call never runs, and its question stays visible.
tools rejects with a TypeError for a tool the agent does not have, and requiresApproval for a
tier no tool of the session carries, the app extensions' included, and neither changes anything.
configure on a child session rejects with SessionOwnedError: its delegate chose what it runs with.
The wire's createSession call takes none of these: what a session runs with is the app's to choose.