feat: populate id field in UiChatLog entries
Summary
This MR implements ID population for UiChatLog entries, ensuring that all messages have proper IDs for tracking and correlation.
Follow-up to the work done in feat: add message_id field to UiChatLog messages (!3948 - merged)
Changes
Implementation
duo_workflow_service/agents/chat_agent.py
- Populate agent message IDs from
AIMessage.id - Generate approval request IDs using tool call ID with
-approvalsuffix - Generate error message IDs using
uuid4()
duo_workflow_service/agents/tools_executor.py
- Populate agent message IDs from
AIMessage.id - Populate tool message IDs from
ToolCall.id - Refactor error handlers to accept
ToolCallinstead of separate name/args parameters
duo_workflow_service/checkpointer/notifier.py
- Populate message IDs from
AIMessage.idwhen appending to UI chat log
duo_workflow_service/workflows/chat/workflow.py
- Generate user message IDs using
uuid4()withuser-prefix
Testing
When I add the following changes to Gitlab Rails:
Click to expand
diff --git a/ee/app/assets/javascripts/ai/duo_agentic_chat/components/duo_agentic_chat.vue b/ee/app/assets/javascripts/ai/duo_agentic_chat/components/duo_agentic_chat.vue
index 953d8333f1df..310a3202b5b5 100644
--- a/ee/app/assets/javascripts/ai/duo_agentic_chat/components/duo_agentic_chat.vue
+++ b/ee/app/assets/javascripts/ai/duo_agentic_chat/components/duo_agentic_chat.vue
@@ -704,6 +704,8 @@ export default {
const messages = WorkflowUtils.transformChatMessages(uiChatLog, this.workflowId);
const [workflow] = data.duoWorkflowWorkflows.nodes ?? [];
+ console.log(messages.map((msg) => msg.id));
+
this.workflowStatus = parsedWorkflowData?.workflowStatus;
this.aiCatalogItemVersionId = workflow?.aiCatalogItemVersionId;
diff --git a/ee/app/assets/javascripts/ai/duo_agentic_chat/utils/workflow_socket_utils.js b/ee/app/assets/javascripts/ai/duo_agentic_chat/utils/workflow_socket_utils.js
index 28298da145c0..cc15f72db8ff 100644
--- a/ee/app/assets/javascripts/ai/duo_agentic_chat/utils/workflow_socket_utils.js
+++ b/ee/app/assets/javascripts/ai/duo_agentic_chat/utils/workflow_socket_utils.js
@@ -98,6 +98,8 @@ export async function processWorkflowMessage(event, workflowId) {
workflowId,
);
+ console.log(messages.map((msg) => msg.id));
+
return {
messages,
status: action.newCheckpoint.status,
I see that id is populated and the id of the streaming message is consistent with the one eventually added to UiChatLog.
Edited by Igor Drozdov