[GH-ISSUE #2990] [BUG]: API endpoint for workspace chats and thread chats are inconsistent and reversed #1912

Closed
opened 2026-02-22 18:27:12 -05:00 by yindo · 1 comment
Owner

Originally created by @mayzyo on GitHub (Jan 19, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2990

Originally assigned to: @shatfield4 on GitHub.

How are you running AnythingLLM?

Docker (remote)

What happened?

When fetching chat history from api/v1/workspace/slug/chats (so the "default" thread) the array is reversed. Additionally, the order of "assistant" and "user" is reversed on top of the whole array being reversed.

Example api/v1/workspace/slug/chats:
The history displayed in the web UI start with me asking "quick test" and assistant replying "How can I assist you?" which is correct.

[
    {
        "attachments": [],
        "chatId": 417,
        "content": "Give me a brief intr",
        "role": "user",
        "sentAt": 1735077496
    },
    {
        "chatId": 417,
        "content": " I am a text-based A",
        "feedbackScore": null,
        "metrics": {
            "completion_tokens": 163,
            "duration": 18.376,
            "outputTps": 8.870265563778842,
            "prompt_tokens": 5,
            "total_tokens": 168
        },
        "role": "assistant",
        "sentAt": 1735077496,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 372,
        "content": "How much water shoul",
        "role": "user",
        "sentAt": 1734609844
    },
    {
        "chatId": 372,
        "content": "The general recommen",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1734609844,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 362,
        "content": "quick test",
        "role": "user",
        "sentAt": 1734470476
    },
    {
        "chatId": 362,
        "content": " How can I assist yo",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1734470476,
        "sources": [],
        "type": "chat"
    }
]

Example api/v1/workspace/slug/threads/tslug/chats:
I believe this is endpoint is the correct one.

[
    {
        "attachments": [],
        "chatId": 341,
        "content": "Hi there!",
        "role": "user",
        "sentAt": 1733646403
    },
    {
        "chatId": 341,
        "content": " Hello! How can I as",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733646403,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 342,
        "content": "What do you know abo",
        "role": "user",
        "sentAt": 1733649565
    },
    {
        "chatId": 342,
        "content": " \"Gundam SEED\" is an",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733649565,
        "sources": [],
        "type": "chat"
    },
    {
        "attachments": [],
        "chatId": 346,
        "content": "Compare seed destiny",
        "role": "user",
        "sentAt": 1733702408
    },
    {
        "chatId": 346,
        "content": "When comparing \"Gund",
        "feedbackScore": null,
        "metrics": {},
        "role": "assistant",
        "sentAt": 1733702408,
        "sources": [],
        "type": "chat"
    }
]

Are there known steps to reproduce?

No response

Originally created by @mayzyo on GitHub (Jan 19, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/2990 Originally assigned to: @shatfield4 on GitHub. ### How are you running AnythingLLM? Docker (remote) ### What happened? When fetching chat history from `api/v1/workspace/slug/chats` (so the "default" thread) the array is reversed. Additionally, the order of "assistant" and "user" is reversed on top of the whole array being reversed. Example `api/v1/workspace/slug/chats`: The history displayed in the web UI start with me asking "quick test" and assistant replying "How can I assist you?" which is correct. ``` [ { "attachments": [], "chatId": 417, "content": "Give me a brief intr", "role": "user", "sentAt": 1735077496 }, { "chatId": 417, "content": " I am a text-based A", "feedbackScore": null, "metrics": { "completion_tokens": 163, "duration": 18.376, "outputTps": 8.870265563778842, "prompt_tokens": 5, "total_tokens": 168 }, "role": "assistant", "sentAt": 1735077496, "sources": [], "type": "chat" }, { "attachments": [], "chatId": 372, "content": "How much water shoul", "role": "user", "sentAt": 1734609844 }, { "chatId": 372, "content": "The general recommen", "feedbackScore": null, "metrics": {}, "role": "assistant", "sentAt": 1734609844, "sources": [], "type": "chat" }, { "attachments": [], "chatId": 362, "content": "quick test", "role": "user", "sentAt": 1734470476 }, { "chatId": 362, "content": " How can I assist yo", "feedbackScore": null, "metrics": {}, "role": "assistant", "sentAt": 1734470476, "sources": [], "type": "chat" } ] ``` Example `api/v1/workspace/slug/threads/tslug/chats`: I believe this is endpoint is the correct one. ``` [ { "attachments": [], "chatId": 341, "content": "Hi there!", "role": "user", "sentAt": 1733646403 }, { "chatId": 341, "content": " Hello! How can I as", "feedbackScore": null, "metrics": {}, "role": "assistant", "sentAt": 1733646403, "sources": [], "type": "chat" }, { "attachments": [], "chatId": 342, "content": "What do you know abo", "role": "user", "sentAt": 1733649565 }, { "chatId": 342, "content": " \"Gundam SEED\" is an", "feedbackScore": null, "metrics": {}, "role": "assistant", "sentAt": 1733649565, "sources": [], "type": "chat" }, { "attachments": [], "chatId": 346, "content": "Compare seed destiny", "role": "user", "sentAt": 1733702408 }, { "chatId": 346, "content": "When comparing \"Gund", "feedbackScore": null, "metrics": {}, "role": "assistant", "sentAt": 1733702408, "sources": [], "type": "chat" } ] ``` ### Are there known steps to reproduce? _No response_
yindo added the possible buginvestigating labels 2026-02-22 18:27:12 -05:00
yindo closed this issue 2026-02-22 18:27:12 -05:00
Author
Owner

@mayzyo commented on GitHub (Jan 19, 2025):

Additionally, it seems like the default thread endpoint is returning history that was already deleted and no longer visible in the web UI. I only noticed this while I was filing this bug report.

@mayzyo commented on GitHub (Jan 19, 2025): Additionally, it seems like the default thread endpoint is returning history that was already deleted and no longer visible in the web UI. I only noticed this while I was filing this bug report.
yindo changed title from [BUG]: API endpoint for workspace chats and thread chats are inconsistent and reversed to [GH-ISSUE #2990] [BUG]: API endpoint for workspace chats and thread chats are inconsistent and reversed 2026-06-05 14:43:25 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#1912