From 5090bf3c3f20b154e8f7d92f25d47f7d7715270d Mon Sep 17 00:00:00 2001 From: Alona <228736368+ak684@users.noreply.github.com> Date: Tue, 1 Dec 2026 21:46:02 +0000 Subject: [PATCH] docs: continue one conversation across Bitbucket Data Center review rounds --- enterprise/automations/data-center-events.mdx | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/enterprise/automations/data-center-events.mdx b/enterprise/automations/data-center-events.mdx index 0d9ade98f..3f99f4d77 100644 --- a/enterprise/automations/data-center-events.mdx +++ b/enterprise/automations/data-center-events.mdx @@ -149,6 +149,81 @@ pullRequest.toRef.displayId == 'main' && pullRequest.toRef.repository.project.ke Try a new automation on a test project or repository before pointing it at production work: it runs for every event its filter matches. +## Keep a Pull Request's Review Rounds in One Conversation + +By default, every matching event starts a new run in a new sandbox, with a fresh clone. For +review comments on a pull request you usually want the opposite: the agent that made the change +should receive each new comment as another message, in the sandbox that still has its checkout. + +An event trigger does this when its `destination` is `continue_conversation`: + +- The first matching event for a pull request starts a run. That run's conversation and sandbox + are kept for the pull request. +- Each later matching event for the same pull request is sent to that conversation as a new + message. No run is created and nothing is cloned again. +- A comment on another pull request gets its own conversation and sandbox. + +The setup form does not offer this setting yet. Create the automation through the API, or create +it in the form and then update its trigger and `keep_alive` with +`PATCH /api/automation/v1/{automation_id}`. + +```http +POST /api/automation/v1/preset/prompt +``` + +```json +{ + "name": "Address review comments: ENG/payments", + "prompt": "A reviewer commented on a pull request in ENG/payments. The event is included above. Check out the pull request's source branch (pullRequest.fromRef.displayId), make the requested change, run the tests, push to that branch, and reply on the pull request with one comment that starts with [openhands]. Later review comments on the same pull request arrive as new messages in this conversation: handle each one in the working tree you already have.", + "repos": [ + { + "url": "https://bitbucket.example.com/scm/eng/payments.git", + "ref": "main", + "provider": "bitbucket_data_center" + } + ], + "keep_alive": true, + "trigger": { + "type": "event", + "source": "bitbucket_data_center", + "on": "pr:comment:added", + "filter": "pullRequest.toRef.repository.project.key == 'ENG' && pullRequest.toRef.repository.slug == 'payments' && comment.author.name != 'svc-openhands' && !starts_with(comment.text, '[openhands]')", + "destination": "continue_conversation", + "subject_key_expr": "join('/', [pullRequest.toRef.repository.project.key, pullRequest.toRef.repository.slug, to_string(pullRequest.id)])", + "turn_text_expr": "join('', ['New review comment from ', comment.author.name, ' on pull request #', to_string(pullRequest.id), ':\n\n', comment.text])" + } +} +``` + +| Field | What it does | +| --- | --- | +| `destination` | `continue_conversation` sends later events to the existing conversation. The default, `dispatch_run`, starts a new run every time. | +| `subject_key_expr` | A JMESPath expression that names what the events are about. Events with the same result share a conversation. The expression above yields `ENG/payments/42` for pull request 42. | +| `turn_text_expr` | A JMESPath expression for the text of each later message. Always set it for Bitbucket Data Center: without it the agent receives the whole event as JSON. | +| `keep_alive` | Keeps the sandbox after the first run finishes. Releases before 0.110.0 do not set it for you; without it the sandbox is deleted and the next comment starts over. | +| `filter` | Must exclude the automation's own replies, or every reply would trigger another message. Exclude the Bitbucket account the automation runs as (`comment.author.name`), a marker its replies start with, or both. | + +The first run receives the full event with the prompt. Later messages contain only what +`turn_text_expr` produces, so put standing instructions in the prompt and tell the agent there +that more comments will follow. + +### Limits + +- **Paused sandboxes.** An idle sandbox is paused after the **Idle Time** set in the Admin Console + (one hour by default; 20 minutes by default on Helm installations). On releases up to 0.124.x, + an event that arrives after the pause starts a new run in a new sandbox instead of continuing + the conversation. Raise the idle time if review rounds are usually further apart than that. +- **Deleted sandboxes.** A paused sandbox is deleted after the **Deletion Time**. The next event + then starts a new run. +- **Running sandboxes per user.** Kept sandboxes count toward **Max Running Sandboxes per User** + for the account the automation runs as. When the limit is reached, that account's oldest running + sandbox is paused. +- **One automation, one source.** The conversation belongs to the automation and its event source. + A conversation started some other way, for example from a Jira issue or by an `@openhands` + mention, is not the one these events continue. +- **Editing the trigger.** The conversation is tied to the automation. Deleting and recreating the + automation starts new conversations for open pull requests. + ## Which Organizations Receive Jira Events A Jira Data Center installation is shared by the whole OpenHands Enterprise installation, so Jira