pm_session
pm_session actions.The pm_session tool manages agent sessions — the running agent workers that execute tasks, do reviews, and produce output. Sessions have ULIDs, worktree configuration, environment, and streaming output.
Use the launch actions to start work, input to continue an existing conversation, and events or delivery receipts to inspect progress. Session creation and provider execution are separate stages: a returned session ID does not mean the agent has completed its task.
Actions
list, get, events, prompt, config, spec, live_deltas, input, start, run, abort, restart, purge, launch_task, launch_prompt, help
list
List agent sessions.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
limit | number | No | Default 200 |
contextRef | string | No | Exact context reference; task launches use TASK-<taskKey>, such as TASK-MYAPI-42 |
get
Fetch a session by ULID.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
events
Fetch the event stream for a session. Events include messages, tool calls, commands, and provider lifecycle markers.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
sinceSeq | integer | No; nonnegative cursor |
limit | integer | No; 1–1000, omitted means all matching events |
For incremental reads, pass the greatest returned event seq as the next sinceSeq. Use a bounded limit to keep large transcripts out of the agent’s context.
prompt
Fetch the stored system prompt that was used when the session launched.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
config
Fetch the parsed provider config used for this session.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
spec
Fetch the full spec details for a session — complete configuration including prompt, tools, worktree, and provider settings.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
live_deltas
Fetch live text deltas (streaming output) from a running session.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
sessionUlid | string | Yes | |
sinceSeq | number | No | Cursor for incremental streaming |
input
Send a prompt/input to an existing session (e.g., answer a question the agent asked, provide additional context). Choose how the message is delivered:
- Queue (
delivery: "queue", the default) waits for the current turn to finish, then dispatches another turn. It can also re-engage idle or closed sessions when the provider supports resume. OpenCode queued follow-ups continue the same conversation. - Steer (
delivery: "steer") sends guidance to an active supported Codex or Claude ad-hoc turn. It requires an active turn; OpenCode and workflow-owned turns do not support steering. Unsupported or inactive targets return an error instead of silently queuing the message.
Use list first, then wake an existing session instead of launching a duplicate reviewer, executor, or auditor.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
sessionUlid | string | Yes | Existing session |
clientRequestId | string | Yes | Fresh idempotency key for each distinct message; use pm_generate_ulid |
prompt | string | Yes | Non-empty message |
delivery | "queue" or "steer" | No | Defaults to "queue" |
Example
pm_session {
action: "input",
sessionUlid: "01HXYZ...",
clientRequestId: "01HABC...",
delivery: "steer",
prompt: "Use the existing MiddlewareChain class instead of creating a new one."
}Delivery result
The structured response identifies the accepted message:
| Field | Meaning |
|---|---|
operationRequestUlid | ID of the recorded input request |
sessionUlid | Target session |
turnClientRequestId | The submitted clientRequestId |
phase | Delivery state, such as queued, dispatching, completed, failed, or ambiguous |
baselineSeq | Session event cursor at acceptance |
delivery | "steer" for steering; an omitted field means queue |
providerTurnId, providerMessageId | Provider acknowledgement identifiers, when available |
error | Failure or uncertain-delivery explanation, when present |
queued means the message was saved for delivery. For steering, completed confirms the provider acknowledged the guidance; the active turn may still be running. Steering failures or uncertain acceptance return isError: true with the structured receipt.
Reuse the same clientRequestId and message when retrying an uncertain request to read its existing receipt. An ambiguous steering request is never automatically submitted again. Inspect the session events before deciding whether another distinct message is needed.
start
Start a provider-backed session. This is the low-level session launch — for task-scoped launches, use launch_task instead.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
clientRequestId | string | Yes | Idempotency key — use pm_generate_ulid |
actor | string | Yes | Who is launching |
contextRef | string | Yes | Context reference (e.g., task key) |
role | string | Yes | Session role |
provider | string | Yes | Provider key |
systemPrompt | string | Yes | System prompt |
launcherConfigKey | string | No | Preset to apply |
worktree | object | No | { baseRef, branchPrefix, templateRef, projectKey, disabled } |
env | array | No | Array of { name, valueRef } |
bootstrapCommands | string[] | No | Commands to run before first turn |
tools | string[] | No | Tool IDs to attach |
config | object | No | Provider config object |
run
Execute a turn for a session.
This is the run action: pm_session { action: "run", sessionUlid: "..." }. It is distinct from the boolean run: true flag on launch_task and restart, which auto-starts the first turn when a session is created or resumed.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
sessionUlid | string | Yes | |
prompt | string | No | Optional prompt for this turn |
configuration | object | No | Config override |
dbPath | string | No | DB path override |
abort
Abort an in-flight run.
Parameters
| Field | Type | Required |
|---|---|---|
sessionUlid | string | Yes |
restart
Restart a closed session using its prior thread/worktree.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
clientRequestId | string | Yes | Idempotency key |
actor | string | Yes | Actor string |
sessionUlid | string | Conditional | One of sessionUlid / providerSessionId required |
providerSessionId | string | Conditional | Existing provider thread id |
prompt | string | No | Optional prompt for the restart run |
run | boolean | No | Dispatch run immediately (default true) |
run: true is an auto-dispatch flag for the resumed session. If you already have an open session and want to send another turn, use the run action instead.
purge
Delete a session and optionally its artifacts. Destructive.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
sessionUlid | string | Yes | |
deleteFiles | boolean | No | Delete transcript/worktree files when true; omitting it removes only session records |
dryRun | boolean | No | Preview without deleting |
purge with dryRun: true first to preview the deletion scope. Omitting deleteFiles removes only session records; pass deleteFiles: true only when you also intend to remove transcript and worktree artifacts.Example
pm_session { action: "purge", sessionUlid: "01HXYZ...", dryRun: true }
pm_session { action: "purge", sessionUlid: "01HXYZ...", deleteFiles: true }launch_task
The high-level task launch — creates a session scoped to a task with full context. This is how orchestrators dispatch work.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
clientRequestId | string | Yes | Idempotency key |
actor | string | Yes | Actor string (e.g., "@pm") |
taskKey | string | Yes | Task key (e.g., "PROJ-123") |
launcherConfigKey | string | Yes | Provider preset key |
agentId | string | No | Specific agent ID |
agentHandle | string | No | Agent handle |
provider | string | No | Provider override (must match provider config) |
role | string | No | Role (default executor) |
prompt | string | No | Optional initial user message override. When provided, launch uses a minimal generated system prompt instead of the built task/capability prompt. |
capabilityKeys | string[] | No | Capability keys to load |
additionalInstructions | string | No | Extra context for this run |
sessionUlidToAudit | string | No | Session to audit (for auditor role) |
sourceSessionUlid | string | No | Reuse an existing worktree from the same task; cannot be combined with worktree |
worktree | object | No | { repoId, requireLinked, baseRef, branchName, branchPrefix, templateRef, disabled } |
worktree.repoId | string | No | Registered project repository to use |
worktree.requireLinked | boolean | No | Create a linked Git worktree for the task |
worktree.branchName | string | No | Full name for a new linked task branch; requires requireLinked: true |
config | object | No | Config overrides |
maxRuntimeSeconds | number | No | Runtime cap |
run | boolean | No | Run immediately after launch (default true) |
The run field here is a boolean auto-start flag. It is not the same as action: "run", which dispatches a turn for an already-started session.
Example
This example chooses the branch name for a new linked task worktree:
pm_session {
action: "launch_task",
clientRequestId: "01HXYZ...",
actor: "@skadi",
taskKey: "MYAPI-42",
launcherConfigKey: "coder-claude",
agentHandle: "claude-coder",
worktree: {
requireLinked: true,
branchName: "feature/myapi-42-rate-limiting"
}
}Use a valid Git branch name. If a local branch with that name already exists, Valdr appends -1, -2, and so on; use the returned branchName for the actual name. Omitting branchName keeps the existing automatic branch-naming behavior; linked worktrees default to valdr-task/<taskKey>.
The task’s project must have an available registered Git repository, and the preset must allow worktree creation. Use worktree.repoId if repository selection is ambiguous. Do not combine requireLinked: true with branchPrefix or disabled, or use this option when reusing a source worktree. Branch naming applies to launch_task creating a new worktree, rather than start, launch_prompt, or session continuation.
The session inherits:
- Task description and acceptance criteria
- Linked requirements
- Capability set from the agent
- Provider config from the preset
- Worktree policy from the preset
Retain the returned session identity and inspect its state or events. Retry an uncertain launch with the same clientRequestId and arguments before creating another execution.
launch_prompt
Launch a taskless session from an authored prompt and saved provider preset. This fits repository exploration or content work that does not need a task record.
| Field | Type | Required | Notes |
|---|---|---|---|
clientRequestId | string | Yes | Stable ID for this launch and its retries |
actor | string | Yes | Who is launching |
prompt | string | Yes | Initial user message |
launcherConfigKey | string | Yes | Existing provider preset key |
agentHandle | string | No | Registry agent whose system prompt is loaded |
contextRef | string | No | Defaults to the source session’s context, or ADHOC-<clientRequestId> |
provider | string | No | Must match the preset’s provider type |
role | string | No | Defaults to executor |
sourceSessionUlid | string | No | Reuse an existing source worktree with worktree.requireLinked: true |
worktree | object | No | Worktree options; linked reuse requires a source session and matching project/repository |
executionProfile | string | No | content_only for a constrained content-generation session |
config | object | No | Provider configuration overrides allowed by the preset |
maxRuntimeSeconds | integer | No | 1–86400 |
run | boolean | No | Dispatch immediately; defaults to true |
pm_session {
action: "launch_prompt",
clientRequestId: "<generated-request-id>",
actor: "@operator",
launcherConfigKey: "<existing-preset-key>",
prompt: "Using only these notes, return a JSON object with an announcement field: this release adds configurable per-IP authentication limits.",
executionProfile: "content_only",
worktree: { disabled: true }
}content_only requires worktree.disabled: true, empty or omitted tools and bootstrapCommands, and no config overrides. The resolved provider must support this profile. Keep the profile unchanged when retrying the same launch ID. For new linked task branches with a chosen name, use launch_task.
help
pm_session { action: "help" }The help payload describes the supported actions, inputs, examples, and cautions.
| Field | Shape | Contents |
|---|---|---|
actions | string[] | Accepted action names, including launch_task, launch_prompt, and help |
whenToUse | object | Action-by-action guidance, including when to re-engage existing sessions with input |
examples | array | Representative calls for context filtering, session input, and task launch |
cautions | string[] | Operator guardrails such as listing before duplicate launches, dry-running purge, and keeping provider secrets out of prompts and comments |
compatibility | string[] | Stability notes, including that closed sessions can remain valid input targets when resume is supported |
Related
- Agent Sessions feature guide — product-level overview of MCP launches, chained execution, and session inspection
- pm_task — sessions launch against tasks
- pm_review —
launch_reviewerwraps session start with review context - pm_audit —
launchwraps session start with audit context - pm_provider — provider presets consumed by
launcherConfigKey - pm_health —
pm_generate_ulidfor idempotency keys