Draft: PoC: continuable Duo Developer sessions (do not merge)
PoC for reference. Do not merge. This branch belongs to the spike #633284 (closed) (epic gitlab-org#24022): Duo Developer sessions started from a mention or an assignment stay open after each answer. The owner can continue them from the session page, and a session that is only done for now shows as idle with no to-do or email. The real implementation will land as separate MRs per issue in the epic. Specs and docs were not kept up to date (several status-list specs fail on purpose).
Gateway side: gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7413 (closed). Pre-push hooks and CI were skipped for this reference push.
What it does
- Status
idle(state 9, its own status group outside "needs attention"). It's resumable by the owner. The server capabilityidle_status_eventtells the gateway this instance accepts it. - Turn ended ≠ session ended.
WorkflowTurnEndedEventfires at every turn end (idle, andfinishedfor the one turn of ambient flows). It's built inside the status transition and carries the turn's final checkpoint and its callback context. Answer delivery (CallbackWorker) hangs on it, andWorkflowFinishedCloudEventkeeps meaning "the session ended". Delivery claims each turn once (TurnDeliveryClaim). The CI-job-ended backstop acts only for the session's latest workload. - Each turn's answer goes where the turn came from. A message that continues a session replaces
messaging_callback_context. The session page and MCP pass none, so their answers stay on the session. Slack session privacy readssource_typeinstead of the callback context. - One decision for "may this user send now, and why not":
Ai::DuoWorkflows::MessageAdmission.- Used by GraphQL
DuoWorkflow.messageInput { enabled, reason }(experiment),POST /resumeand MCP. - A per-session lease serializes sends, as a stopgap until ai-assist#2877.
- Messages go through
ExecuteRunServiceasinputevents. Decisions keep master's resume path and403answers, now with a reason.
- Used by GraphQL
- Session page:
- a reply box for conversational sessions the viewer owns, disabled with a reason when a message can't go now;
- messages queue during a turn through the shared chat
PromptQueue(drainMode: 'all', item states) and go out as one batch; - updates come from the
workflowEventsUpdatedsubscription, with polling as the fallback.
- Version:
duo_developer_continuable_sessionsmakes the Developer definition resolve^4.0.0for new sessions. A resumed CI turn keeps its first job's constraint (master's behaviour).
Not behind the flag (on purpose, to ship sequenced)
Rails accepting idle, delivery on the turn-ended event for every messaging flow (two releases: handle, then publish and subscribe), serialized /resume, and the extra subscription push when a CI job ends.
Try it in GDK
- Enable
duo_developer_continuable_sessionsfor your user and run the gateway branch. - Mention
@GitLabDuoon an issue. Expected: the answer lands in the thread, the session shows Idle, no to-do. - Open the session and send a follow-up. Expected: a new CI job, the answer on the session page, no new note in the thread.
- Send two more messages while that turn runs. Expected: they queue and go out as one follow-up when the turn ends.
- Send twice at once through
POST /api/v4/ai/duo_workflows/workflows/:id/resume. Expected:201and409with a reason, one CI job.
Known gaps
- A batch accepted just before a page reload can show "Not sent", and Retry sends it twice. Fixed later with server-side message IDs.
- Features that wait for "session finished" (for example !261137 (merged)) don't fire for resting sessions.
- The GraphQL subscription sends
workflowStatus: IDLEunprojected to older IDEs. - Workhorse has no "accepted" signal between enqueue and pickup.
- Not measured: latency and cost of a follow-up turn on GitLab.com.