Skip to content

An open-source, faster Devin alternative

TypeScript

docs: Linear agent connection and the ask question surface

Igor Zalutski148af45930de
diff --git a/docs/agents/api.mdx b/docs/agents/api.mdx
index 8e9bca2c..810ac204 100644
--- a/docs/agents/api.mdx
+++ b/docs/agents/api.mdx
@@ -137,8 +137,9 @@ not active in the named environment), `402 insufficient_credits`.
| `labels`, `labelsUpdatedAt` | Your metadata, and when it last changed; see [Labels](#labels) |
| `externalReference` | The reference given at creation; absent when none was given |
| `memory` | Bindings with `resource`, `scope`, `id`, `access` and `writable`; present when the session was created with bindings |
-| `turns` | Every turn: `id`, `input`, `mode`, `status`, `createdAt`, `updatedAt`, and `deliveries` when an [event subscription](#event-subscriptions) selected its outcome |
+| `turns` | Every turn: `id`, `input`, `mode`, `status`, `createdAt`, `updatedAt`; `outcome: "question"` on a completed turn that ended by asking; and `deliveries` when an [event subscription](#event-subscriptions) selected its outcome |
| `result` | The latest committed output of the agent's [result tool](/agents/tools#the-session-result), or `null`: `{ turnId, callId, reportedAt, data }`. `turnId` and `callId` name the call that reported `data`, so a reader can tell which turn it came from and whether a later turn changed things without reporting. A failed or cancelled turn never clears it. |
+| `question` | The open [question](/agents/sessions#questions) the agent asked with `ask`, or `null`: `{ id, text, options, askedAt }`, `options` an array of `{ label, value }`, empty for free text. Independent of `result`. |
| `revision` | A counter that increases with every change to the session's status, turns, labels or result |
| `createdAt`, `updatedAt` | Timestamps |
@@ -323,6 +324,7 @@ are present they must be equal, else `400 invalid_turn`.
| `idempotencyKey` | Optional. The key in body form, for a proxied browser send; equal to the header when both are present. |
| `mode` | `queue` (default): run after earlier turns. `steer`: deliver into the running turn when the runtime supports it, otherwise queue. `interrupt`: interrupt running turns and run next, with the [same settlement behavior](#end-and-interrupt) as the interrupt route. |
| `payload` | Optional. A JSON value for the agent, at most 32 KB encoded. It reaches the agent as [`useInput().payload`](/agents/inputs) with `source: "user"`, next to the text, and is recorded on the turn's `message.received` event. The text stays the message; the payload is structured context the agent reads. |
+| `answers` | Optional. The id of the session's open [question](/agents/sessions#questions). The input answers it, and the agent reads it as [`useInput().answer`](/agents/inputs#answers-and-steering). |
The response is `202 { turnId, status, duplicate }` for a new turn and
`200` with `duplicate: true` when the key had already created one. `status`
@@ -339,8 +341,21 @@ idempotency_conflict` and admits nothing. A retry after a lost reply is
therefore safe with the same body, and a different request never lands on
another request's key.
+While the session has an open question, a turn sent without `answers` is
+held rather than run: the response is `202 { status: "held", duplicate }`
+with no `turnId`. The held input is delivered with the answer, in order, as
+the answering turn's `steering`. A repeat of its key after the answer returns
+the answering turn's receipt; after the session is stopped from
+[Linear](/agents/linear#stop), it returns `status: "discarded"`.
+
+A turn with `answers` resolves the question and runs as the answer, in one
+step, idempotent on its key. Naming a question that is not the open one, or
+answering when none is open, is `409 question_stale`; read the session and
+answer its current question.
+
Codes: `400 invalid_turn`, `400 invalid_payload` (over 32 KB),
`402 insufficient_credits`, `409 idempotency_conflict`,
+`409 question_stale`,
`409 memory_admission_pending` (retry the session creation with its key
first), `409 memory_admission_rejected` (the session is ended; create a new
one).
@@ -509,6 +524,50 @@ The delivered event names identifiers and the outcome; a completed turn's
final message is included, bounded to 16 KB. The receiving agent should
treat that text as data about another agent's work, not as instructions.
+## Linear connections
+
+A [Linear connection](/agents/linear) binds a Linear app in your workspace to
+one agent in one environment. The dashboard drives these routes; they need an
+organization API key, and project-scoped keys are refused.
+
+| Operation | Method and path | Body or query | Success |
+| --- | --- | --- | --- |
+| Create | `POST /projects/<p>/linear/connections` | `{ name, environment, agentId }` | `201` with `{ connectionId, webhookUrl, createAppUrl, connection }`; `200` when a pending connection for that binding already exists |
+| List | `GET /projects/<p>/linear/connections` | Optional `?environment=` | `200` with `{ connections }` |
+| Set credentials | `PUT /linear/connections/<id>/credentials` | `{ clientId, clientSecret, signingSecret }`, as copied from the Linear app | `200` with `{ connection }` |
+| Authorize | `POST /linear/connections/<id>/authorize` | None | `200` with `{ authorizeUrl, expiresAt }` |
+| Disconnect | `DELETE /linear/connections/<id>` | None | `200` with `{ connection, revoked }` |
+
+`createAppUrl` opens Linear's create-app page prefilled with the name, the
+callback URL and `webhookUrl`. `webhookUrl` contains the connection's secret;
+treat it as a credential. `authorizeUrl` is Linear's consent page for the app;
+a workspace admin completes it, and Linear returns to OpenComputer's callback,
+which stores the tokens and redirects to the project's Connections tab.
+`revoked` on a disconnect says whether Linear confirmed the token revocation.
+
+A connection is `{ id, projectId, environment, agentId, name, status,
+clientId, appUserId, organizationId, webhookUrl, createAppUrl, verifiedAt,
+verificationError, lastEventAt, teams, health, revision, createdAt,
+updatedAt }`. It never carries a secret or a token. `status` is `pending`,
+`connected`, `disconnected` or `revoked`. `health` is `{ state, message,
+lastEventAt? }`, with `state` one of `awaiting_credentials`,
+`awaiting_authorization`, `waiting_for_first_delegation`, `receiving` or
+`revoked`. `teams` is `{ allPublic, teamIds }`, the teams the app can see.
+
+| Code | Meaning |
+| --- | --- |
+| `400 invalid_environment`, `400 invalid_agent` | `environment` must be `development` or `production`; `agentId` must name an agent of the project |
+| `400 invalid_linear_app_name` | The name must be 1 to 64 characters |
+| `400 linear_app_name_reserved` | Linear does not allow app names that contain "Linear" |
+| `400 invalid_linear_credentials` | `clientId`, `clientSecret` and `signingSecret` are all required |
+| `404 linear_connection_not_found` | No such connection, or it was disconnected |
+| `409 linear_already_connected` | The agent already has a connection in this environment; `error.connectionId` names it |
+| `409 linear_app_already_connected` | That Linear app is connected to another agent or environment; create a separate app |
+| `409 linear_connection_connected` | The connection is authorized with a different Linear app; disconnect it first |
+| `409 linear_credentials_required` | Set the credentials before authorizing |
+| `409 linear_connection_changed` | Another request changed the connection; list the connections and continue; `error.connectionId` names it |
+| `503 linear_connector_unavailable` | Linear connections are not available right now |
+
## Projects, agents and deployments
| Operation | Method and path | Success |
diff --git a/docs/agents/events.mdx b/docs/agents/events.mdx
index 720eb51d..8c34b9d6 100644
--- a/docs/agents/events.mdx
+++ b/docs/agents/events.mdx
@@ -70,9 +70,9 @@ remote cleanup continues in the background.
| `turn.steered` | The input was delivered into the running turn | `activeTurnId` |
| `turn.interrupted` | This turn requested interruption of the running turns | `interruptedTurnIds` |
| `turn.started` | The runtime began the turn | none |
-| `turn.completed` | The turn finished and the session is idle again | none |
+| `turn.completed` | The turn finished and the session is idle again | none, or `outcome: "question"` and `questionId` when the turn ended by [asking](#questions) |
| `turn.failed` | The turn stopped with an error | `code`, `message`, and `model` or `tool` when named: a [public failure](#public-failures) |
-| `turn.cancelled` | The turn was cancelled by an interrupt or session end | `reason`: `interrupted` or `session_ended`; optional `replacementTurnId`, `settledAfterMs`, `operationsSettled`, `computerTerminated` |
+| `turn.cancelled` | The turn was cancelled by an interrupt or session end, held behind a question, or stopped from Linear | `reason`: `interrupted`, `session_ended`, `held` or `stopped`; optional `replacementTurnId`, `settledAfterMs`, `operationsSettled`, `computerTerminated`; `questionId` with `held`; `discarded: true` on a queued turn a stop discarded |
For an interrupt that waits for commands, `settledAfterMs` records the wait,
`operationsSettled` counts the settled commands, and `computerTerminated`
@@ -81,6 +81,10 @@ says whether stopping required terminating the computer. Cancellation with
decision to end, before remote cleanup finishes. Immediate-cancellation
sessions also omit these fields; see [End and interrupt](/agents/api#end-and-interrupt).
+A turn that was queued behind a turn that asked a question is cancelled
+with `reason: "held"` and the `questionId`: its input did not run on its own
+and is delivered with the answer as `steering`.
+
#### Public failures
A failure's `data` is a stable `code`, a fixed `message` for that code, and
@@ -117,6 +121,21 @@ only when one happened.
| `model_stream_failed` | The model call failed before it finished, or its response stream broke; when it was retried, the retry failed too | `model`: the model id, when known |
| `agent_failed` | Any other failure | |
+### Questions
+
+| Type | When | `data` |
+| --- | --- | --- |
+| `question.asked` | The agent called [`ask`](/agents/tools#ask-a-question); the asking turn completes with `outcome: "question"` | `questionId`, `text`, `options`: `{ label, value }` choices, empty for free text |
+| `question.answered` | A turn answering the question was admitted | `questionId`, `answer`: `{ questionId, text, value? }` |
+| `question.closed` | The question closed without an answer | `questionId`, `reason`: `stopped` |
+
+`turn.completed` with `outcome: "question"` is the turn's terminal event, so a
+consumer that knows only completed turns reads an asking turn correctly, and
+[outcome subscriptions](/agents/api#event-subscriptions) deliver it as a
+completed turn. The open question is also on the session as
+[`question`](/agents/sessions#questions). A question closes with `stopped`
+when the session is stopped from [Linear](/agents/linear#stop).
+
### Messages
| Type | When | `data` |
diff --git a/docs/agents/inputs.mdx b/docs/agents/inputs.mdx
index 2af23dac..99cffc58 100644
--- a/docs/agents/inputs.mdx
+++ b/docs/agents/inputs.mdx
@@ -27,6 +27,8 @@ interface AgentInput {
readonly source: InputSource;
readonly text?: string;
readonly payload?: DataValue;
+ readonly answer?: QuestionAnswer;
+ readonly steering?: readonly HeldInput[];
}
```
@@ -35,6 +37,8 @@ interface AgentInput {
| `source` | How the work entered the session: `user`, `channel`, `schedule`, `webhook`, `subagent`, `system` or `event` |
| `text` | Optional human-readable message |
| `payload` | Optional structured JSON value supplied by the source |
+| `answer` | Present only when this input answers the question an earlier turn asked; see [Answers and steering](#answers-and-steering) |
+| `steering` | Inputs written while that question was open that did not answer it, in order |
`DataValue` means any JSON-compatible value: `null`, a boolean, number,
string, array, or object. Both `text` and `payload` are optional, so check them
@@ -53,6 +57,31 @@ when Slack supplies them. An agent serving one workspace can ignore all of
this; an agent behind a shared Slack app uses it to decide whose records to
read.
+A message from a [Linear connection](/agents/linear) also arrives with
+`source: "channel"`, with `channel.provider` set to `linear`,
+`channel.workspaceId` the Linear workspace, `channel.conversationId` the
+Linear agent session and `channel.userId` the person who wrote the message.
+Its `payload` is a `LinearInputPayload`: the issue, the session, the thread's
+comments, your workspace's guidance for agents, and `origin`, which says
+whether the issue had a parent and whether this agent's own app created it.
+`origin` is read when the session starts and does not change afterwards. The
+fields are listed on [Linear agents](/agents/linear#what-the-agent-receives).
+
+```tsx
+import { useInput, type LinearInputPayload } from "@opencomputer/agent";
+
+export default function Agent() {
+ const input = useInput();
+ if (input.source === "channel" && input.channel.provider === "linear") {
+ const linear = input.payload as unknown as LinearInputPayload;
+ return linear.origin.createdByAgent && linear.origin.parent
+ ? `Implement ${linear.issue.identifier}, part of ${linear.origin.parent.identifier}.`
+ : `Investigate ${linear.issue.identifier} and propose an approach.`;
+ }
+ return `Help with: ${input.text ?? "the current request"}`;
+}
+```
+
## Adapt to the source
The current direct and delegated flows can share one agent definition:
@@ -133,11 +162,57 @@ The platform attests where the input came from through `source`; the
included message is another agent's output and is data to reason about, not
instructions to follow.
+## Answers and steering
+
+A turn can end with a question: the agent selects the
+[`ask`](/agents/tools#ask-a-question) tool and the model calls it. The
+reply is the next input, from any source, with `answer` set:
+
+| Field | Meaning |
+| --- | --- |
+| `answer.questionId` | The question this input answers |
+| `answer.text` | What the person wrote or selected |
+| `answer.value` | The chosen option's `value`, when the text matched an option by value or label |
+
+Input that arrives while the question is open without answering it does not
+run a turn of its own. It is held and delivered with the answer as
+`steering`, in the order it arrived:
+
+| Field | Meaning |
+| --- | --- |
+| `text`, `payload`, `channel` | The held input, as it would have arrived on its own |
+| `receivedAt` | When OpenComputer received it |
+| `providerTime` | When the provider says it was written, when it says |
+
+Read `steering` before acting on the answer. A constraint written while the
+question was open can change what a "go" means, and the agent should revise
+its proposal rather than act on an answer the steering has overtaken.
+
+```tsx
+import { useInput, useTool } from "@opencomputer/agent";
+
+export default function Agent() {
+ const input = useInput();
+ if (input.answer) {
+ const held = (input.steering ?? []).map((item) => `- ${item.text ?? ""}`).join("\n");
+ return `The person answered: ${input.answer.value ?? input.answer.text}.${
+ held ? `\nWritten meanwhile, read before acting:\n${held}` : ""
+ }`;
+ }
+ useTool("ask");
+ return "Read the request, propose a plan, and ask before making changes.";
+}
+```
+
+`answer` and `steering` sit beside `payload`, not inside it, so they read the
+same from every source and never collide with an application's payload.
+
## Input is not a prompt UI
-`useInput()` only reads admitted input. It does not pause the session to ask a
-person a question. The durable conversation and later messages are managed by
-the [session](/agents/sessions).
+`useInput()` only reads admitted input. It does not itself pause the session
+to ask a person a question; a turn asks with the [`ask`](/agents/tools#ask-a-question)
+tool, and the answer arrives as a later input. The durable conversation and
+later messages are managed by the [session](/agents/sessions).
Input payload also differs from [session data](/agents/session-data): a payload
belongs to the current input, while session data can persist across renders.
diff --git a/docs/agents/linear.mdx b/docs/agents/linear.mdx
new file mode 100644
index 00000000..edd5cd12
--- /dev/null
+++ b/docs/agents/linear.mdx
@@ -0,0 +1,330 @@
+---
+title: "Linear agents"
+description: "Connect a deployed agent to Linear as a teammate people delegate issues to and mention"
+---
+
+A Linear connection makes a deployed agent a member of your Linear workspace.
+People delegate issues to it and mention it in comments, under the name and
+icon you give its Linear app. Each conversation is a Linear agent session with
+its own activity thread on the issue, and OpenComputer runs it as one session
+of your agent.
+
+There is no webhook handler, Linear client or reply code to write. The agent
+reads each message with [`useInput()`](/agents/inputs), its tool calls and
+final message are posted to the thread as Linear activities, and it can stop
+and ask a question with [`ask`](/agents/tools#ask-a-question). When it needs
+more than its thread (a document, a sub-issue, a status change), it calls
+Linear through the managed [`linear` service](/agents/services) as its own app.
+
+The connection is a Linear app created in your workspace and bound to one
+agent in one environment of a project. Development and Production are
+separate connections with separate apps.
+
+## Connect Linear
+
+After the project's deployment is synchronized:
+
+1. Open the project in the dashboard and select **Development** or
+ **Production**.
+2. Open **Connections** and, in the Linear panel, choose **Create Linear
+ agent**. Enter the name people will see in Linear. Linear does not allow
+ app names that contain "Linear".
+3. OpenComputer allocates the connection and its webhook URL, then opens
+ Linear's create-app page prefilled with the name, the callback URL, and
+ webhooks enabled on the webhook URL shown in the dashboard for agent
+ session, permission change and authorization events. Create the app. It is
+ private to your workspace.
+4. Copy the app's **client ID**, **client secret** and **webhook signing
+ secret** from Linear and paste them into the dashboard.
+5. Choose **Authorize in Linear** and approve the installation. A workspace
+ admin must complete this step. The app is installed as an app user with
+ permission to read, write, be delegated issues and be mentioned. You are
+ returned to the same project and environment.
+
+The panel then shows the connection's health:
+
+| State | Shown as | Meaning |
+| --- | --- | --- |
+| `awaiting_credentials` | Create the app in Linear, then paste its credentials | The connection exists; the app's credentials are not stored yet |
+| `awaiting_authorization` | Authorize the app in Linear to finish setup | Credentials are stored; the app is not installed yet |
+| `waiting_for_first_delegation` | Waiting for the first delegation | The app is installed; no event from Linear has arrived yet |
+| `receiving` | First session received | A real Linear event reached the agent; the time of the latest one is shown |
+| `revoked` | The app's access was revoked in Linear | Authorize it again to reconnect |
+
+Delegate an issue to the agent, or mention it, to confirm delivery. The
+connection also records which teams the app can see, and follows the changes
+Linear reports to that access.
+
+Credentials and tokens are stored encrypted. Linear's access tokens expire
+daily and OpenComputer refreshes them; no token reaches the agent, its logs or
+the browser.
+
+## Where people talk to it
+
+- **Delegate an issue** to the agent. This opens an agent session on the issue.
+- **Mention the agent** in a comment. This opens a separate agent session on
+ that comment's thread.
+- **Reply in the session's thread.** A reply continues that session, including
+ after the agent has finished.
+
+A top-level comment that does not mention the agent is not delivered to it.
+An issue can carry several agent sessions, one per delegation or mentioned
+thread; each is its own OpenComputer session. When a reply arrives for a
+session that has ended in OpenComputer, a new session continues the same
+Linear thread.
+
+Sessions started from Linear belong to the connection, not to the person who
+wrote the message. Anyone on the team can reply in the thread, and the agent
+answers the thread.
+
+Linear needs to see the agent respond within seconds. OpenComputer accepts
+each event before answering Linear and posts a short first activity itself,
+before your agent's runtime starts, so a slow start shows as a working agent
+rather than an unresponsive one.
+
+## What the agent receives
+
+A message from Linear arrives as a [channel input](/agents/inputs):
+`source: "channel"`, with `channel.provider` set to `"linear"`. `text` is
+Linear's prompt context for the first message of a session (the issue, the
+thread and your workspace's guidance for agents, as Linear writes it), and the
+message body for every later one.
+
+| Field | Meaning |
+| --- | --- |
+| `channel.connectionId` | The Linear connection the message arrived on |
+| `channel.workspaceId` | The Linear workspace |
+| `channel.conversationId` | The Linear agent session |
+| `channel.userId` | The Linear user who wrote the message |
+
+`payload` is a `LinearInputPayload`, exported by `@opencomputer/agent`:
+
+| Field | Meaning |
+| --- | --- |
+| `action` | `created` for the message that opened the session, `prompted` for a later one |
+| `issue` | `{ id, identifier, title, description, url, team: { id, key, name } }`, as this message carried it |
+| `origin.parent` | `{ id, identifier }` of the issue's parent, when it had one |
+| `origin.createdByAgent` | `true` when this agent's own Linear app created the issue |
+| `session` | `{ id, url, creator? }`; `creator` is the person responsible for the session and is absent when automation started it |
+| `promptContext` | Linear's prompt context, when the session began with a delegation or mention |
+| `comment` | `{ id, body }`, the thread's root comment, when the session is a comment thread |
+| `previousComments` | Earlier comments of that thread, as Linear sent them |
+| `guidance` | Your workspace and team guidance for agents, as Linear sent it |
+
+`origin` is read from Linear when the session starts and never changes for
+that session. A parent can be changed in Linear later; `origin` still says
+what was true when the work began, so a decision the agent made from it on the
+first message holds on every later one. `issue` is the issue as each message
+delivered it. OpenComputer attaches no role or meaning to these facts. An
+agent can, for example, treat an issue its own app created under a parent as
+work it already planned and act on it directly, and treat everything else as
+a request to investigate first.
+
+Linear's workspace and team guidance is the natural place for conventions
+that apply to every agent in your workspace; it reaches the agent in `text`
+and `guidance` without any code.
+
+## What the agent writes
+
+The agent does not post to Linear itself. OpenComputer turns the session into
+Linear activities, in order, on the agent session's thread:
+
+| The agent | Appears in Linear as |
+| --- | --- |
+| Calls a tool | An action with the tool's name, a one-line summary of what it did and a one-line result, after the call returns |
+| Works on a long call | An occasional "Still working." thought, so the session does not go stale |
+| Finishes its turn | A response with the final message |
+| Ends its turn with `ask` | A question awaiting input, with any options as buttons |
+| Fails | An error: "OpenComputer could not complete this request." |
+| Is stopped | An error: "Stopped." |
+
+Raw tool arguments and outputs are never copied to Linear. The full trace stays
+in the session's [event log](/agents/events) in OpenComputer. Tool activity is
+limited to one per call and one every few seconds per session.
+
+When the final message contains a GitHub pull request URL, it is set as the
+session's external link, which Linear shows as the pull request.
+
+## Ask a question
+
+A turn can end with a question instead of a final answer. Select the
+platform's [`ask`](/agents/tools#ask-a-question) tool; when the model calls
+it, the turn ends and Linear shows the session as awaiting input. Options are
+rendered as buttons. Linear shows them only while the session is awaiting
+input, and a click sends the option's `value` as the reply.
+
+The reply arrives as the next input with `answer` set:
+`{ questionId, text, value? }`, where `value` is the chosen option's value when
+the reply matches an option by value or label. Whether a message answers the
+question is decided by when it was written in Linear, not when it arrived: a
+message written after the question answers it.
+
+### Messages written while the agent works
+
+Linear holds a message someone types while the agent is working, and offers to
+send it. It releases held messages only when the agent finishes with a response
+or an error, not when it asks a question. So a constraint typed while the agent
+was working reaches the agent before the answer only if the person sends it
+before answering; otherwise it arrives after the answer turn, as an ordinary
+message.
+
+Messages written before the question and delivered while it is open never
+answer it. They are held and delivered with the answer, in order, as
+`steering`. Read them before acting on the answer: they may change what the
+answer should mean.
+
+Write questions that say this, for example "Messages you typed while I was
+working are still held; send them before answering."
+
+## Stop
+
+The stop control in Linear stops the agent at once:
+
+- the running turn is interrupted;
+- queued and held messages for that session are discarded;
+- an open question is closed;
+- the thread shows "Stopped." once the interrupt has settled.
+
+Stop ends the turn, not the session. A later reply in the same thread starts a
+new turn on the same session. Stop applies to that session only; issues the
+agent delegated from it keep running.
+
+## Call Linear from the agent
+
+The thread is written for you. For anything else (a document, sub-issues, a
+status change, a comment elsewhere), declare the managed `linear` service and
+call Linear's GraphQL API with [`callService`](/agents/services). In a session
+started from a Linear connection, the call acts as the agent's own Linear app,
+with the connection's token attached by the platform.
+
+```tsx
+// tools/create-sub-issue.ts
+import { callService, defineTool } from "@opencomputer/agent";
+
+export const createSubIssue = defineTool({
+ name: "create_sub_issue",
+ description: "Create a sub-issue under a Linear issue",
+ input: {
+ type: "object",
+ properties: {
+ teamId: { type: "string" },
+ parentId: { type: "string" },
+ title: { type: "string" },
+ description: { type: "string" },
+ },
+ required: ["teamId", "parentId", "title"],
+ additionalProperties: false,
+ },
+ async run({ input, signal }) {
+ const response = await callService({
+ service: "linear",
+ method: "POST",
+ path: "/graphql",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({
+ query: `mutation Create($input: IssueCreateInput!) {
+ issueCreate(input: $input) { success issue { id identifier url } }
+ }`,
+ variables: { input },
+ }),
+ signal,
+ });
+ const result = (await response.json()) as {
+ data?: { issueCreate?: { issue?: { id: string; identifier: string; url: string } } };
+ errors?: Array<{ message: string }>;
+ };
+ if (!response.ok || result.errors?.length) {
+ throw new Error(result.errors?.[0]?.message ?? `linear: ${response.status}`);
+ }
+ return result.data?.issueCreate?.issue ?? null;
+ },
+});
+```
+
+Only `POST /graphql` is accepted. In a session the connection owns, the
+`linear` service resolves to the app and nothing else: no person's connected
+Linear account is used, and a `label` is ignored. The deployment must declare
+`useService("linear")`. The same code in a session someone started from your
+application uses that person's connected Linear account instead, as described
+on [Connected services](/agents/services).
+
+Delegating an issue to the agent's own app user, for example with
+`issueCreate` and a `delegateId`, opens a new agent session on that issue,
+which arrives as a new `created` message with `origin.createdByAgent: true`.
+
+To work on code, connect the project's [GitHub App](/agents/github); sessions
+started from Linear reach GitHub through it.
+
+## A minimal agent
+
+```tsx
+// agent.ts
+import {
+ useInput,
+ useService,
+ useTool,
+ type LinearInputPayload,
+} from "@opencomputer/agent";
+import { createSubIssue } from "./tools/create-sub-issue";
+
+export default function Agent() {
+ const input = useInput();
+ useService("linear");
+
+ if (input.source !== "channel" || input.channel.provider !== "linear") {
+ return `Help with: ${input.text ?? "the current request"}`;
+ }
+ const linear = input.payload as unknown as LinearInputPayload;
+ const issue = `${linear.issue.identifier} "${linear.issue.title}" (team ${linear.issue.team.id}, issue id ${linear.issue.id})`;
+
+ if (input.answer) {
+ useTool(createSubIssue);
+ const steering = (input.steering ?? [])
+ .map((held) => `- ${held.text ?? ""}`)
+ .join("\n");
+ return [
+ `You are working on ${issue}.`,
+ `Your question was answered: ${input.answer.value ?? input.answer.text}.`,
+ steering
+ ? `These messages were written before the answer and may change what it means:\n${steering}`
+ : "",
+ "If the answer is go, create the sub-issues you proposed. Otherwise revise the proposal.",
+ ].join("\n\n");
+ }
+
+ useTool("ask");
+ return [
+ `You were asked to help with ${issue}.`,
+ input.text ?? "",
+ "Propose how to split this into sub-issues, then call ask with the options go and revise.",
+ "Say that messages typed while you were working are still held, so they should be sent before answering.",
+ ].join("\n\n");
+}
+```
+
+The first turn can only read its input and ask; creating sub-issues is
+selected only on the turn that carries the answer. `ask` records a question;
+what a turn can do before it asks is decided by the tools that turn selects.
+
+## Disconnect
+
+Choose **Disconnect** in the Linear panel. OpenComputer stops accepting events
+for the connection, revokes the app's token in Linear and removes the binding,
+so the agent and environment can be connected again. The Linear app itself
+stays in your workspace; delete it in Linear if you no longer need it.
+
+If an admin revokes the app's access in Linear, the connection is marked
+revoked and receives nothing until it is authorized again from the panel.
+
+## Current limits
+
+- One Linear connection per agent per environment, and one connection per
+ Linear app. To connect a second agent or environment, create a separate app.
+- There is no per-connection concurrency limit. Every delegated issue and
+ mentioned thread runs its own session, so a large delegated backlog runs
+ many sessions at once.
+- `ask` runs on the default runtime for new deployments; sessions with
+ `executionMode: "microvm"` cannot select it.
+- Stopping a session does not stop issues it delegated, and cancelling an
+ issue in Linear does not stop its session.
+- The app is private to the workspace it was created in.
diff --git a/docs/agents/react.mdx b/docs/agents/react.mdx
index 0d49821a..7a22c0d1 100644
--- a/docs/agents/react.mdx
+++ b/docs/agents/react.mdx
@@ -45,7 +45,7 @@ The hook needs these [management API](/agents/api) routes, relative to its
| Route | Purpose |
| --- | --- |
| `GET /sessions/<id>/events?after=<seq>` | Read conversation history and new events |
-| `POST /sessions/<id>/turns` | Submit `{ input, idempotencyKey, payload? }` |
+| `POST /sessions/<id>/turns` | Submit `{ input, idempotencyKey, payload?, answers? }` |
| `POST /sessions/<id>/interrupt` | Request Stop for the running turn |
Authenticate each request and check access to the session before forwarding
@@ -179,6 +179,7 @@ confirms that message instead of adding a second one.
| --- | --- |
| `idempotencyKey` | One key per submission, reused on retries. Without it, **each call** generates a new key and can admit a new turn. |
| `payload` | Structured JSON available to the agent as `useInput().payload`, beside the text |
+| `answers` | The id of the open question this input answers; `answer()` sets it |
`send` rejects with a `SendError`. Rejection alone does **not** establish
whether a turn was admitted:
@@ -219,6 +220,7 @@ to distinguish queued work from running and settled turns:
| `toolCalls` | `{ callId, tool, title, input?, output?, status }` in start order; values are decoded JSON |
| `result` | This turn's latest committed [result-tool output](/agents/tools#the-session-result), if any; ordinary tool output does not become a result |
| `failure` | `{ code, message }` from `turn.failed` |
+| `outcome` | `"question"` when the turn completed by asking |
Reporting a result does not finish a turn. The session's latest result may
also belong to an earlier turn; see [result provenance](/agents/sessions)
@@ -237,6 +239,38 @@ a queued turn is visible in `turns` but does not by itself set `isRunning`.
Use `turns` for queued/running counts and the [session API](/agents/api#sessions)
for session status.
+## Answer a question
+
+An agent can end a turn by [asking a question](/agents/tools#ask-a-question).
+The hook exposes the open question as `question`, `{ id, text, options,
+turnId? }`, or `null`, and `answer(questionId, text, options?)` sends the
+reply. The asking turn's `outcome` is `"question"`.
+
+```tsx
+const { question, answer } = useAgent({ sessionId, basePath: "/api/agent" });
+
+{question ? (
+ <section>
+ <p>{question.text}</p>
+ {question.options.map((option) => (
+ <button
+ key={option.value}
+ onClick={() => void answer(question.id, option.value, { idempotencyKey: `${question.id}:${option.value}` })}
+ >
+ {option.label}
+ </button>
+ ))}
+ </section>
+) : null}
+```
+
+`answer(id, text, options)` is `send(text, { ...options, answers: id })`
+and resolves with the same receipt. `options` is empty for a free-text
+question; answer it with the person's text. `question` clears when the
+log records `question.answered` or `question.closed` for it. Answering a
+question that is no longer open rejects with a `SendError` whose code is
+`question_stale`; the hook's `question` shows the current one.
+
## Stop and reopen
`stop()` requests an interrupt without spending a model turn. It resolves
@@ -330,6 +364,8 @@ code.
| `turns` | Turns with status, input, messages, tool calls, result and failure |
| `send(text, options?)` | Submit a turn; resolve with a receipt or reject with `SendError` |
| `stop()` | Request an interrupt; rejects with `SendError` on a failed request, settlement arrives in `turns` |
+| `question` | The open question, `{ id, text, options, turnId? }`, or `null` |
+| `answer(questionId, text, options?)` | Answer the open question; same receipt and errors as `send` |
| `sessionId` | Attached session, or the created one after the first send |
| `isRunning` | Running activity or this instance's unsettled admissions; not a session status |
| `isReplaying` | Attach mode: existing history is still loading |
diff --git a/docs/agents/services.mdx b/docs/agents/services.mdx
index 981b24a4..6359a7a8 100644
--- a/docs/agents/services.mdx
+++ b/docs/agents/services.mdx
@@ -215,6 +215,24 @@ Linear may report GraphQL errors in a successful HTTP response, so check both
`response.ok` and `errors`. The Linear connection accepts only `POST /graphql`;
other paths and methods fail at the broker.
+### Linear in sessions started from Linear
+
+Which credential a call uses follows who owns the session. In a session
+someone started, `service: "linear"` uses a Linear account connected as
+above. In a session started from a [Linear agent connection](/agents/linear),
+the session belongs to the connection, and `service: "linear"` resolves to
+that connection's own Linear app: the call acts as the agent, under the name
+people delegate to, with the app's token attached by the platform.
+
+- No person's connected Linear account is used in those sessions, and there
+ is no fallback to one; a `label` is ignored.
+- The deployment must declare `useService("linear")`.
+- Only `POST /graphql` is accepted, as everywhere.
+
+The agent's code is the same in both kinds of session. Writes made through
+the app, such as a sub-issue or a comment, are attributed to the agent in
+Linear.
+
## 4. Several accounts
Accounts are connected and disconnected long after the artifact is built, so
diff --git a/docs/agents/sessions.mdx b/docs/agents/sessions.mdx
index 00c3c73b..afb3ec66 100644
--- a/docs/agents/sessions.mdx
+++ b/docs/agents/sessions.mdx
@@ -66,6 +66,7 @@ These describe different parts of a session:
| `status` and `activity` | Is work queued, running, stopping or finished? |
| `labels` | How does your application organize the session? A ticket ID or `archived` label is your convention; changing it does not stop work. |
| `result` | What did the agent last report? Its `data` is validated against the [result tool's](/agents/tools#the-session-result) output schema; `turnId` and `callId` identify the report. |
+| `question` | Is the agent waiting on a person? The open [question](#questions), or `null`. |
A report does not finish a turn, and each report replaces the whole result.
Later work can run, fail or be cancelled while an earlier result remains.
@@ -73,6 +74,56 @@ For a review queue, check current activity, the last settled turn's status,
and whether `result.turnId` matches that turn before treating the report as
ready. Your application decides what the reported data means.
+## Questions
+
+A turn can end by asking. When the agent calls the
+[`ask`](/agents/tools#ask-a-question) tool, the turn completes with
+`outcome: "question"` and the session's `question` is set:
+
+```json
+{
+ "question": {
+ "id": "<question-id>",
+ "text": "Plan first, or go ahead?",
+ "options": [{ "label": "Go", "value": "go" }, { "label": "Plan first", "value": "plan" }],
+ "askedAt": "2026-10-02T10:00:00.000Z"
+ }
+}
+```
+
+`options` is empty for a free-text question. `question` is `null` when
+nothing is open, and it is independent of `result`: a session can hold a
+result and an open question at the same time. A consumer that only knows
+completed turns still reads an asking turn correctly, because its status is
+`completed`.
+
+Answer by sending a turn that names the question with `answers`:
+
+```ts
+await oc.sessions.turns.send(sessionId, {
+ input: "Go",
+ answers: session.question!.id,
+ idempotencyKey: "answer-1",
+});
+```
+
+The agent reads the reply as [`useInput().answer`](/agents/inputs#answers-and-steering).
+Naming a question that is not the open one is refused with
+`409 question_stale`; read the session again and answer its current
+question.
+
+While a question is open, a turn sent without `answers` does not run on its
+own. It is held, and delivered with the answer, in order, as `steering`, so
+the turn that interprets the answer sees every constraint written in the
+meantime. The API answers a held input with `status: "held"`; see
+[Turns](/agents/api#turns). A turn already queued behind the asking turn is
+held the same way.
+
+One question is open at a time. The answering turn may ask again, which opens
+a new question. A question closes without an answer only when the session is
+stopped from [Linear](/agents/linear#stop), which also discards the held
+inputs.
+
## Durability and recovery
Closing the browser or redeploying your application does not discard work
diff --git a/docs/agents/tools.mdx b/docs/agents/tools.mdx
index 88070add..5ccf48ed 100644
--- a/docs/agents/tools.mdx
+++ b/docs/agents/tools.mdx
@@ -271,6 +271,59 @@ For Google services, GitHub, or Linear, the credential belongs to whoever
connected the account and the platform refreshes it — call those with
[`callService`](/agents/services) instead.
+## Ask a question
+
+`ask` is the platform's question tool. Select it with `useTool("ask")` when a
+turn may need to stop and ask a person before going on:
+
+```tsx
+import { useInput, useTool } from "@opencomputer/agent";
+
+export default function Agent() {
+ const input = useInput();
+ if (input.answer) {
+ return `The answer was ${input.answer.value ?? input.answer.text}. Proceed accordingly.`;
+ }
+ useTool("ask");
+ return "Read the request, propose an approach, and ask whether to go ahead.";
+}
+```
+
+The model calls it with:
+
+| Field | Bounds |
+| --- | --- |
+| `text` | The question, 1 to 4000 characters |
+| `options` | Optional, at most six `{ label, value }` choices; each `label` and `value` 1 to 80 characters |
+
+Calling `ask` ends the turn with an open question. The turn completes with
+`outcome: "question"`, the session's `question` holds what was asked, and
+`question.asked` is recorded in the [event log](/agents/events#questions).
+The reply arrives as the next input with
+[`answer`](/agents/inputs#answers-and-steering) set, and anything written
+meanwhile arrives with it as `steering`. A session has at most one open
+question; the turn that interprets the answer may ask again.
+
+How the question reaches a person depends on where the session lives: an
+application answers it through the [API](/agents/api#turns) or the
+[React hook](/agents/react#answer-a-question), and a
+[Linear](/agents/linear#ask-a-question) session shows it in the thread with
+the options as buttons.
+
+`ask` records that the agent asked. It does not undo or forbid anything the
+turn did before asking. A turn meant only to propose should select `ask` and
+tools that cannot write, and select the writing tools on the turn that
+carries the answer.
+
+The id `ask` is reserved: `defineTool({ name: "ask" })` is refused, both by
+`defineTool` and by the CLI's build. `ask` runs on the default runtime for new deployments;
+sessions with `executionMode: "microvm"` cannot select it.
+
+`ask` is different from [waiting for a person](#wait-for-a-person-before-writing):
+`ask` ends a turn with an open question the agent reasons about when it is
+answered, while an approval tool records one exact write that runs, unchanged,
+once someone approves it.
+
## Wait for a person before writing
Some writes should not happen because a model decided they should. Such a tool
diff --git a/docs/docs.json b/docs/docs.json
index e1302c30..c84ee6eb 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -49,6 +49,7 @@
"agents/services",
"agents/github",
"agents/slack",
+ "agents/linear",
"agents/byok",
"agents/deployments"
]
diff --git a/docs/reference/typescript-sdk/agents.mdx b/docs/reference/typescript-sdk/agents.mdx
index 4d4857e3..b47bb29c 100644
--- a/docs/reference/typescript-sdk/agents.mdx
+++ b/docs/reference/typescript-sdk/agents.mdx
@@ -122,7 +122,8 @@ its contents affect application correctness or access.
`create` takes `agentId`, `deploymentId`, `environment`, `memory`, `source`,
`labels` and `externalReference` as [documented](/agents/api#create). `turns.send` takes `input`,
-`idempotencyKey`, `mode` and `payload`; both `create` and `turns.send` send
+`idempotencyKey`, `mode`, `payload` and `answers`, the id of the open
+[question](/agents/sessions#questions) the input answers; both `create` and `turns.send` send
the key as the `Idempotency-Key` header. The receipt carries the turn's
persisted `status`: `queued` or `running` for a new turn, and for a repeated
key the existing turn's status, `completed`, `failed` or `cancelled` once it