threads.create
Creates a thread in an existing or a new workspace; an agent’s parentThreadId (its own thread) makes it a child, nested under the parent (readOnly by default for windows, AGT-420, AGT-421). tools limits its agent to the tools named (exact names the model sees), [] to none at all (AGT-500, AGT-501). ephemeral: true makes a disposable thread, deleted with its session once its run settled and nothing waits for it, listed in the left column only while it needs the user (DMN-1400).
Params: CreateThreadParams
Section titled “Params: CreateThreadParams”/** `threads.create` params. */export type CreateThreadParams = { /** The thread's approval mode; default `yolo` (DMN-952). An agent may not set it (DMN-956). */ approvalMode?: ApprovalMode | null; /** * A disposable thread (DMN-1400): deleted with its session once a run of its agent settled and nothing waits for * it (no dialog, background job or running child); the left column lists it only while it needs the user (UI-1205). * Default `false`. */ ephemeral?: boolean | null; /** Images of the first message, sent with `prompt`; a first message may be images only (DMN-211). */ images?: unknown[]; /** `provider/id`. */ model?: string | null; /** * For agents only (AGT-420): the calling agent's own thread, making the new thread its child, nested under it in * the left column, in its workspace (`workspace` may be left out), at most `agents.maxDepth` levels below a thread * without a parent (`limit_reached` deeper). A window's call with it is `unauthorized`. */ parentThreadId?: string | null; /** * With `parentThreadId`: windows may show the child but not send it anything (`thread.prompt`, `thread.steer`, * `thread.follow_up` and `thread.bash` from a window answer `unauthorized`, AGT-421). Default `true`. */ readOnly?: boolean | null; /** * First message, sent once the thread is created; when the thread's host cannot start for it (`thread_failed`), * the thread is not created (DMN-211). */ prompt?: string | null; thinkingLevel?: unknown; /** For scripts and agents; without it the title is generated from the conversation (DMN-1070). */ title?: string | null; /** * The thread's only tools, by the names the model sees (AGT-500): `[]` gives its agent no tool at all (AGT-501). * Exact names of the thread's tools, of the workspace's declared tools or `mcp__<server>__<tool>`; an unknown name * is `bad_request`. Absent or `null`: every tool. Fixed for the thread's life; its children and forks inherit it. */ tools?: string[] | null; /** Required: `{ "id": … }` for an existing workspace or `{ "new": { "name"?, "link"? } }` for a new one. */ workspace: ThreadWorkspace;};Result: ThreadSummary
Section titled “Result: ThreadSummary”/** What the thread list shows about a thread. */export type ThreadSummary = { /** * The background jobs the thread's agent started that run, then the newest of those that ended, at most 3, in the * order they started (PRT-354); absent when there is none. */ agentJobs?: AgentJob[]; /** * The thread's approval mode (DMN-952, PRT-450): set by `threads.create` / `threads.update`, inherited by a fork; * absent for `yolo`, the default. */ approvalMode?: ApprovalMode | null; archivedAt?: number | null; createdAt: number; /** A disposable thread (`threads.create { ephemeral: true }`, DMN-1400); absent for any other. */ ephemeral?: boolean; /** * How many parents up to a thread without one (AGT-420): 1 for a child, 2 for a child's child; absent for a thread * without a parent (depth 0). */ depth?: number; /** The thread this one was forked from (`threads.fork`, DMN-1072); absent for a thread that is no fork. */ forkedFrom?: ForkOrigin | null; id: string; /** * When the daemon stopped (unix ms) while the thread's agent was mid-turn or waiting on async work: its last turn * was interrupted by a daemon restart and nothing continued it since (PRT-229, DMN-1071). `thread.resume` * continues it; any message to the thread clears it. Absent otherwise. */ interruptedAt?: number | null; /** Interactive requests are waiting for an answer. */ needsAttention: boolean; /** * Its place among the threads of its workspace (archived ones included) in the left column, from 0; the same in * every window (DMN-282). */ position: number; /** * The thread whose agent started this one as its child (a subagent, `task`, or `threads.create` with * `parentThreadId`, AGT-420); absent for a thread without a parent. */ parentThreadId?: string; /** Whether the thread's host runs, starts, stopped or failed. */ process: ProcessState; provenance: Provenance; /** A child that windows may show but not send anything (AGT-421); absent when they may. */ readOnly?: boolean; /** Idle with nothing queued or pending (pi's `agent_settled`). */ settled: boolean; /** `""` until the first message (DMN-1070). */ title: string; titleSource: TitleSource; /** The thread's only tools (`threads.create`'s `tools`, AGT-500, PRT-490); absent for a thread with every tool. */ tools?: string[]; updatedAt: number; /** The workspace the thread lives in: its session's working directory is the workspace folder. */ workspaceId: string;};Types they use
Section titled “Types they use”/** * A thread's approval mode: which tool calls the thread's host asks the user to approve before they run (DMN-952, * DMN-953). Read-only tools run without asking in every mode; any other value is `bad_request`. */export type ApprovalMode = /** Runs read-only tools; asks before every other tool, file edits included. */ | "always-ask" /** * Like `always-ask`, but the question can allow the tool (for `omfp_call`, that method) for the rest of the * thread host's session (DMN-954). */ | "always-ask-cached" /** Runs read-only tools and file edits (`edit`, `write`); asks before the rest (the shell, evals, …). */ | "write" /** Runs every tool without asking (the default). */ | "yolo";
/** The workspace of a new thread. */export type ThreadWorkspace = /** An existing workspace. */ | { id: string; } /** * A new workspace, as `workspaces.create` makes it; its name defaults to the thread's title, else to the first * words of its first message. */ | { new: CreateWorkspaceParams; };
/** * A background job a thread's agent started (`job_start`, AGT-320), as its summary lists it (PRT-354): its id, its * command, its state as `jobs.output` reports it (PRT-351) and its exit code once it exited. */export type AgentJob = { command: string; /** `null` while it runs or when a signal ended it. */ exitCode: number | null; jobId: string; /** The label its agent gave it (`job_start`'s `name`). */ name?: string | null; /** `completed` on exit 0, `failed` on another exit or a signal, `cancelled` when killed (PRT-351). */ state: "running" | "completed" | "failed" | "cancelled";};
/** Where a forked thread comes from (PRT-401): the source thread and the message it was forked at. */export type ForkOrigin = { /** The pi session entry the fork ends at; absent when the whole session was copied. */ entryId?: string | null; /** The first line of that entry's message text (at most 120 characters). */ message?: string | null; /** The source thread; it may have been deleted since. */ threadId: string; /** The source's title when it was forked. */ title: string;};
/** Who created an entity. */export type Provenance = { /** `client` of the creating connection's `system.hello`. */ client?: string | null; createdBy: CreatedBy;};
/** Where a thread's title comes from (DMN-1070). */export type TitleSource = /** The first words of the first message (or `""` before it), until a title is generated or set. */ | "placeholder" /** Generated from the conversation by the daemon. */ | "generated" /** Set by the user or an agent (`threads.create`, `threads.update`, `agents.set_title`); never replaced. */ | "set";
/** `workspaces.create` params (DMN-930). */export type CreateWorkspaceParams = { /** An existing directory to link into the new folder (a symlink named after it) in the same call. */ link?: string | null; /** Unique name; default: the folder name of `link` when given, else `workspace` (made unique). */ name?: string | null;};
/** * The principal behind a created entity: the user, the agent of a thread, or an MCP client outside omfp, * named by the provenance's `client`. */export type CreatedBy = | { kind: "user"; } | { kind: "thread"; threadId: string; } | { kind: "mcp"; } /** A run of the declared job `job` of the entity's workspace (PRT-209). */ | { job: string; kind: "job"; };