[PR #4668] [MERGED] Implement full chat and @agent chat user indentificiation for OpenRouter #4710

Closed
opened 2026-02-22 18:36:22 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4668
Author: @timothycarambat
Created: 11/20/2025
Status: Merged
Merged: 11/20/2025
Merged by: @timothycarambat

Base: masterHead: 4453-openrouter-user-id


📝 Commits (1)

  • 5057abd Implmenet chat and agentic chat user-id for OpenRouter

📊 Changes

7 files changed (+51 additions, -5 deletions)

View changed files

📝 server/utils/AiProviders/openRouter/index.js (+7 -2)
📝 server/utils/agents/aibitat/index.js (+5 -3)
📝 server/utils/agents/aibitat/providers/ai-provider.js (+29 -0)
📝 server/utils/agents/aibitat/providers/openrouter.js (+4 -0)
📝 server/utils/chats/apiChatHandler.js (+3 -0)
📝 server/utils/chats/stream.js (+2 -0)
📝 server/utils/helpers/index.js (+1 -0)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • [] ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4453
closes #4482

What is in this change?

  • Adds an optional user record in getChatCompletion and streamCompletion in chat that can be used in any provider, but this PR only adds it for OpenRouter currently.

  • Also adds context and tracking for user and general invocation on the Aibitat Provider so that we can easily get references to the calling record and user at any time

Additional Information

  • Since all of this is optional, this should have no impact on existing providers.
  • No tracking was added to LLMInstruction calls from agent flows or EphemeralAgent API based calls - since they may not have a user associated.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality

Tested normal chats, agent chats, and API chats w/&w/o agents for workspace & thread sync and stream with multiple providers in addition to OR.

  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/4668 **Author:** [@timothycarambat](https://github.com/timothycarambat) **Created:** 11/20/2025 **Status:** ✅ Merged **Merged:** 11/20/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `4453-openrouter-user-id` --- ### 📝 Commits (1) - [`5057abd`](https://github.com/Mintplex-Labs/anything-llm/commit/5057abd4ec07b6f44b2817f3cdce4f031a836786) Implmenet chat and agentic chat user-id for OpenRouter ### 📊 Changes **7 files changed** (+51 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/AiProviders/openRouter/index.js` (+7 -2) 📝 `server/utils/agents/aibitat/index.js` (+5 -3) 📝 `server/utils/agents/aibitat/providers/ai-provider.js` (+29 -0) 📝 `server/utils/agents/aibitat/providers/openrouter.js` (+4 -0) 📝 `server/utils/chats/apiChatHandler.js` (+3 -0) 📝 `server/utils/chats/stream.js` (+2 -0) 📝 `server/utils/helpers/index.js` (+1 -0) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat - [ ] 🐛 fix - [] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4453 closes #4482 ### What is in this change? - Adds an optional `user` record in `getChatCompletion` and `streamCompletion` in chat that can be used in any provider, but this PR only adds it for OpenRouter currently. - Also adds context and tracking for user and general `invocation` on the Aibitat `Provider` so that we can easily get references to the calling record and user at any time <!-- Describe the changes in this PR that are impactful to the repo. --> ### Additional Information - Since all of this is optional, this should have no impact on existing providers. - No tracking was added to `LLMInstruction` calls from agent flows or `EphemeralAgent` API based calls - since they may not have a user associated. <!-- Add any other context about the Pull Request here that was not captured above. --> ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality > Tested normal chats, agent chats, and API chats w/&w/o agents for workspace & thread sync and stream with multiple providers in addition to OR. - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:36:22 -05:00
yindo closed this issue 2026-02-22 18:36:22 -05:00
yindo changed title from [PR #4668] Implement full chat and `@agent` chat `user` indentificiation for OpenRouter to [PR #4668] [MERGED] Implement full chat and `@agent` chat `user` indentificiation for OpenRouter 2026-06-05 15:19:57 -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#4710