diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 6adeb6f7..ec137589 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -94,6 +94,7 @@ export namespace SessionPrompt {
})
.optional(),
agent: z.string().optional(),
+ noReply: z.boolean().optional(),
system: z.string().optional(),
tools: z.record(z.string(), z.boolean()).optional(),
parts: z.array(
@@ -142,6 +143,11 @@ export namespace SessionPrompt {
const userMsg = await createUserMessage(input)
await Session.touch(input.sessionID)
+ // Early return for context-only messages (no AI inference)
+ if (input.noReply) {
+ return userMsg
+ }
+
if (isBusy(input.sessionID)) {
return new Promise((resolve) => {
const queue = state().queued.get(input.sessionID) ?? []
diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts
index 3cf13691..47bb2097 100644
--- a/packages/sdk/js/src/gen/types.gen.ts
+++ b/packages/sdk/js/src/gen/types.gen.ts
@@ -1894,6 +1894,7 @@ export type SessionPromptData = {
modelID: string
}
agent?: string
+ noReply?: boolean
system?: string
tools?: {
[key: string]: boolean
diff --git a/packages/web/src/content/docs/sdk.mdx b/packages/web/src/content/docs/sdk.mdx
index 6d66cebf..07166165 100644
--- a/packages/web/src/content/docs/sdk.mdx
+++ b/packages/web/src/content/docs/sdk.mdx
@@ -209,27 +209,27 @@ const { providers, default: defaults } = await client.config.providers()
### Sessions
-| Method | Description | Notes |
-| ---------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
-| `session.list()` | List sessions | Returns Session[] |
-| `session.get({ path })` | Get session | Returns Session |
-| `session.children({ path })` | List child sessions | Returns Session[] |
-| `session.create({ body })` | Create session | Returns Session |
-| `session.delete({ path })` | Delete session | Returns `boolean` |
-| `session.update({ path, body })` | Update session properties | Returns Session |
-| `session.init({ path, body })` | Analyze app and create `AGENTS.md` | Returns `boolean` |
-| `session.abort({ path })` | Abort a running session | Returns `boolean` |
-| `session.share({ path })` | Share session | Returns Session |
-| `session.unshare({ path })` | Unshare session | Returns Session |
-| `session.summarize({ path, body })` | Summarize session | Returns `boolean` |
-| `session.messages({ path })` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` |
-| `session.message({ path })` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` |
-| `session.prompt({ path, body })` | Send prompt message | Returns `{ info: `AssistantMessage`, parts: `Part[]`}` |
-| `session.command({ path, body })` | Send command to session | Returns `{ info: `AssistantMessage`, parts: `Part[]`}` |
-| `session.shell({ path, body })` | Run a shell command | Returns AssistantMessage |
-| `session.revert({ path, body })` | Revert a message | Returns Session |
-| `session.unrevert({ path })` | Restore reverted messages | Returns Session |
-| `postSessionByIdPermissionsByPermissionId({ path, body })` | Respond to a permission request | Returns `boolean` |
+| Method | Description | Notes |
+| ---------------------------------------------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
+| `session.list()` | List sessions | Returns Session[] |
+| `session.get({ path })` | Get session | Returns Session |
+| `session.children({ path })` | List child sessions | Returns Session[] |
+| `session.create({ body })` | Create session | Returns Session |
+| `session.delete({ path })` | Delete session | Returns `boolean` |
+| `session.update({ path, body })` | Update session properties | Returns Session |
+| `session.init({ path, body })` | Analyze app and create `AGENTS.md` | Returns `boolean` |
+| `session.abort({ path })` | Abort a running session | Returns `boolean` |
+| `session.share({ path })` | Share session | Returns Session |
+| `session.unshare({ path })` | Unshare session | Returns Session |
+| `session.summarize({ path, body })` | Summarize session | Returns `boolean` |
+| `session.messages({ path })` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` |
+| `session.message({ path })` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` |
+| `session.prompt({ path, body })` | Send prompt message | `body.noReply: true` returns UserMessage (context only). Default returns AssistantMessage with AI response |
+| `session.command({ path, body })` | Send command to session | Returns `{ info: `AssistantMessage`, parts: `Part[]`}` |
+| `session.shell({ path, body })` | Run a shell command | Returns AssistantMessage |
+| `session.revert({ path, body })` | Revert a message | Returns Session |
+| `session.unrevert({ path })` | Restore reverted messages | Returns Session |
+| `postSessionByIdPermissionsByPermissionId({ path, body })` | Respond to a permission request | Returns `boolean` |
---
@@ -251,6 +251,15 @@ const result = await client.session.prompt({
parts: [{ type: "text", text: "Hello!" }],
},
})
+
+// Inject context without triggering AI response (useful for plugins)
+await client.session.prompt({
+ path: { id: session.id },
+ body: {
+ noReply: true,
+ parts: [{ type: "text", text: "You are a helpful assistant." }],
+ },
+})
```
---
diff --git a/packages/web/src/content/docs/server.mdx b/packages/web/src/content/docs/server.mdx
index e1d02622..3d880fb7 100644
--- a/packages/web/src/content/docs/server.mdx
+++ b/packages/web/src/content/docs/server.mdx
@@ -88,26 +88,26 @@ The opencode server exposes the following APIs.
### Sessions
-| Method | Path | Description | Notes |
-| -------- | ---------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `GET` | `/session` | List sessions | Returns Session[] |
-| `GET` | `/session/:id` | Get session | Returns Session |
-| `GET` | `/session/:id/children` | List child sessions | Returns Session[] |
-| `POST` | `/session` | Create session | body: `{ parentID?, title? }`, returns Session |
-| `DELETE` | `/session/:id` | Delete session | |
-| `PATCH` | `/session/:id` | Update session properties | body: `{ title? }`, returns Session |
-| `POST` | `/session/:id/init` | Analyze app and create `AGENTS.md` | body: `{ messageID, providerID, modelID }` |
-| `POST` | `/session/:id/abort` | Abort a running session | |
-| `POST` | `/session/:id/share` | Share session | Returns Session |
-| `DELETE` | `/session/:id/share` | Unshare session | Returns Session |
-| `POST` | `/session/:id/summarize` | Summarize session | |
-| `GET` | `/session/:id/message` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` |
-| `GET` | `/session/:id/message/:messageID` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` |
-| `POST` | `/session/:id/message` | Send chat message | body matches [`ChatInput`](https://github.com/sst/opencode/blob/main/packages/opencode/src/session/index.ts#L358), returns Message |
-| `POST` | `/session/:id/shell` | Run a shell command | body matches [`CommandInput`](https://github.com/sst/opencode/blob/main/packages/opencode/src/session/index.ts#L1007), returns Message |
-| `POST` | `/session/:id/revert` | Revert a message | body: `{ messageID }` |
-| `POST` | `/session/:id/unrevert` | Restore reverted messages | |
-| `POST` | `/session/:id/permissions/:permissionID` | Respond to a permission request | body: `{ response }` |
+| Method | Path | Description | Notes |
+| -------- | ---------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `GET` | `/session` | List sessions | Returns Session[] |
+| `GET` | `/session/:id` | Get session | Returns Session |
+| `GET` | `/session/:id/children` | List child sessions | Returns Session[] |
+| `POST` | `/session` | Create session | body: `{ parentID?, title? }`, returns Session |
+| `DELETE` | `/session/:id` | Delete session | |
+| `PATCH` | `/session/:id` | Update session properties | body: `{ title? }`, returns Session |
+| `POST` | `/session/:id/init` | Analyze app and create `AGENTS.md` | body: `{ messageID, providerID, modelID }` |
+| `POST` | `/session/:id/abort` | Abort a running session | |
+| `POST` | `/session/:id/share` | Share session | Returns Session |
+| `DELETE` | `/session/:id/share` | Unshare session | Returns Session |
+| `POST` | `/session/:id/summarize` | Summarize session | |
+| `GET` | `/session/:id/message` | List messages in a session | Returns `{ info: `Message`, parts: `Part[]`}[]` |
+| `GET` | `/session/:id/message/:messageID` | Get message details | Returns `{ info: `Message`, parts: `Part[]`}` |
+| `POST` | `/session/:id/message` | Send chat message | body matches [`ChatInput`](https://github.com/sst/opencode/blob/main/packages/opencode/src/session/index.ts#L358). Optional `noReply: true` skips AI inference and returns UserMessage. Returns Message |
+| `POST` | `/session/:id/shell` | Run a shell command | body matches [`CommandInput`](https://github.com/sst/opencode/blob/main/packages/opencode/src/session/index.ts#L1007), returns Message |
+| `POST` | `/session/:id/revert` | Revert a message | body: `{ messageID }` |
+| `POST` | `/session/:id/unrevert` | Restore reverted messages | |
+| `POST` | `/session/:id/permissions/:permissionID` | Respond to a permission request | body: `{ response }` |
---