Show a chat error when the workflow service rejects a request

What does this MR do and why?

Show a chat error when the workflow service rejects a request and raises InvalidRequestException.

Currently, when a user using Duo agentic chat sends a new message with a resume_checkpoint_ts that does not exist, the Python code will close the connection and return an error, but this error is not displayed to the user. This leaves the message the user just sent with no response. If the user reloads the page, their message will disappear as well.

resume_checkpoint_ts is sent when:

  1. Retrying a message. Sends the parent_ts of the user message they are retying. Creates a new branch in the thread.
  2. Switching branch sends the last thread_ts of the branch the user wants to switch to. After they retried, if they want to switch back to another branch.

This MR will detect the error and display it to the user. 3 places raise InvalidRequestException and the errors the frontend renders are:

  1. When the client sends a resume_checkpoint_ts that does not exist (main reason for MR)
  2. The user client sends resume_checkpoint_ts on a chat that does not accept it.
  3. When on a flow based chat and no content is sent.

image.png

References

Retry epic: gitlab-org#21289

How to set up and validate locally

Invalid resume_checkpoint_ts (Main reason for MR)

  1. In gitlab-ai-gateway/duo_workflow_service/server.py update resume_checkpoint_ts=start_workflow_request.startRequest.resume_checkpoint_ts to resume_checkpoint_ts="123"
  2. gdk restart duo-workflow-service
  3. Send any new message

When flow does not accept retries

  1. In gdk rails c Feature.enable(:agentic_chat_flow_registry_migration)
  2. Reload page after 5 seconds, and start a new Duo agentic chat.
  3. In gitlab-ai-gateway/duo_workflow_service/server.py update resume_checkpoint_ts=start_workflow_request.startRequest.resume_checkpoint_ts to resume_checkpoint_ts="123"
  4. gdk restart duo-workflow-service
  5. Send any new message

Flow with no content:

  1. In gdk rails c Feature.enable(:agentic_chat_flow_registry_migration)
  2. Reload page after 5 seconds, and start a new Duo agentic chat.
  3. Send any message.
  4. In gitlab-ai-gateway/duo_workflow_service/server.py update workflow_task = asyncio.create_task(workflow.run(goal)) to workflow_task = asyncio.create_task(workflow.run(""))
  5. gdk restart duo-workflow-service
  6. Send any new message

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 Kaveh Nejad

Merge request reports

Loading
Loading