Paginate the Duo session chat log and cap duoMessages

What does this MR do and why?

Paginate the Duo session chat log and cap duoMessages

Reading a session's chat log through duoMessages returned every message with no bound, and the session page polled it every 10 seconds.

References

https://gitlab.com/gitlab-org/gitlab/-/work_items/635073

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Enable FF duo_workflow_cap_duo_messages
  2. Run a workflow that takes multiple steps (e.g. ask Developer @duo-developer-gitlab-duo - Write a python script that tells me the time, but it's always wrong.)
  3. Check you can get the messages, newest first, with pagination, within messages:
  query testCheckPointPagination{
    duoWorkflowWorkflows(workflowId: "gid://gitlab/Ai::DuoWorkflows::Workflow/4960") {
      nodes {
        id
        latestCheckpoint {
          threadTs
          duoMessages { content role threadTs parentTs alternativeCount }
          messages(last: 2) {
            nodes { content messageType role threadTs }
            pageInfo { hasPreviousPage hasNextPage startCursor endCursor }
          }
        }
      }
    }
  }
  1. To test the cap, set DUO_MESSAGES_CAP in workflow_event_type.rb to 2, and rerun the above query. The duoMessages should be limited to 2 with the FF on, and not limited with it off.

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.

Edited by Roman Eisner

Merge request reports

Loading
Loading