Expose thread_ts and parent_thread_ts
What does this MR do and why?
Expose thread_ts and parent_thread_ts
Allow FE to request thread_ts and parent_thread_ts, the FE can use these to fork from the checkpoints during retries.
Python MR has added the ability for the Python code to accept a resume_checkpoint_ts which is forwarded onto LangGraph to indicate that the user is A) creating a new branch with that thread as the parent (retrying a message with a duplicate). B) Selecting an existing branch to carry on from. This MR allows the FE to see the thread_ts and resume_checkpoint_ts of each message, so it is aware of which to send to the Python.
For example in the following conversation:
Say 1 thread_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf parent_ts: 1f18b420-2d1f-6ba0-bfff-e5880762ca33
1 thread_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186 parent_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf
Which page am I on? thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **Work items** page for th… thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186If the user sends 1f18b420-43e9-63d1-8001-ddf0ad2a7186 as the resume_checkpoint_ts twice with the same message content but from a different page, they will create a thread like:
Say 1 thread_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf parent_ts: 1f18b420-2d1f-6ba0-bfff-e5880762ca33
1 thread_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186 parent_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf
Which page am I on? thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **Work items** page for th… thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
Which page am I on? thread_ts: 1f18b422-3be7-60a8-8002-a51ca0a88812 parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **Test** project page (git… thread_ts: 1f18b422-504f-6aec-8003-bebe3575e92e parent_ts: 1f18b422-3be7-60a8-8002-a51ca0a88812
Which page am I on? thread_ts: 1f18b422-c315-64a6-8002-2670783ab71d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **GitLab Duo** page (http:… thread_ts: 1f18b422-d458-6fe6-8003-cb13182a64da parent_ts: 1f18b422-c315-64a6-8002-2670783ab71dIf they then send 1f18b422-504f-6aec-8003-bebe3575e92e as the resume_checkpoint_ts for "Say 2"they are choosing the middle answer as the main answer. Creating:
Say 1 thread_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf parent_ts: 1f18b420-2d1f-6ba0-bfff-e5880762ca33
1 thread_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186 parent_ts: 1f18b420-2d24-6f99-8000-bd98b2b46daf
Which page am I on? thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **Work items** page for th… thread_ts: 1f18b420-8623-610c-8002-2f358ff2639d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
Which page am I on? thread_ts: 1f18b422-3be7-60a8-8002-a51ca0a88812 parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **Test** project page (git… thread_ts: 1f18b422-504f-6aec-8003-bebe3575e92e parent_ts: 1f18b422-3be7-60a8-8002-a51ca0a88812
Say 2 thread_ts: 1f18b429-ec48-6762-8004-446ffc760468 parent_ts: 1f18b422-504f-6aec-8003-bebe3575e92e
2 thread_ts: 1f18b429-fd51-6c32-8005-07544e486e85 parent_ts: 1f18b429-ec48-6762-8004-446ffc760468
Which page am I on? thread_ts: 1f18b422-c315-64a6-8002-2670783ab71d parent_ts: 1f18b420-43e9-63d1-8001-ddf0ad2a7186
You're on the **GitLab Duo** page (http:… thread_ts: 1f18b422-d458-6fe6-8003-cb13182a64da parent_ts: 1f18b422-c315-64a6-8002-2670783ab71dAt this point, a duoWorkflowWorkflows request should not return the 1st and last "Which page am I on?"a and the responses "Work items" and "Gitlab Duo"
References
Full PoC: gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!6124 (closed)
Epic: gitlab-org#21289
Python implementation for retries: gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!6356 (merged)
Comment with plan from @mikolaj_wawrzyniak (Slight variations): gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!6124 (comment 3622972972)
Video demo: gitlab-org#21289 (comment 3666671057)
How to set up and validate locally
-
Enable flags for incremental checkpoints:
Feature.enable(:duo_workflow_incremental_checkpoints)Feature.enable(:duo_workflow_read_incremental_checkpoints)Feature.enable(:dw_read_blobs_graphql)
-
Create a simple chat with a few messages
-
In http://gdk.test:8080/-/graphql-explorer run
{ duoWorkflowWorkflows(workflowId: "gid://gitlab/Ai::DuoWorkflows::Workflow/<Workflow ID>") { nodes { latestCheckpoint { duoMessages { content messageType threadTs parentTs } } } } }- ID can be found in ws in the network tab, or
Ai::DuoWorkflows::Workflow.last.id.
- ID can be found in ws in the network tab, or
-
Confirm messages have
thread_ts, andparent_thread_ts. -
Without flags enabled, they should return null.
Optional tests:
- With tool calls/approvals
- Follow steps in gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!6356 (merged) to make a thread with multiple branches.
- Only the latest branch should be returned. If 3 branches (A, B, and C), C should be returned.
- Use step 10 in above MR to mark B as chosen. B should be returned, and A/C ignored.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.