fix: assistant for project does not work#7509
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes project-created threads not applying their assistant instructions by ensuring the thread’s assigned assistant is always used to generate the systemMessage passed into the chat transport.
Changes:
- Remove the
projectId-based guard that prevented usingthread.assistants[0]when the thread belongs to a project.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (4)
web-app/src/services/tests/threads.test.ts:4
- Unused imports ConversationalExtension, ExtensionTypeEnum.
import { ConversationalExtension, ExtensionTypeEnum } from '@janhq/core'
web-app/src/services/tests/threads.test.ts:206
- Unused variable result.
const result = threadsService.updateThread(thread as Thread)
web-app/src/services/tests/threads.test.ts:363
- Unused variable result.
const result = await threadsService.createThread(inputThread as Thread)
web-app/src/services/tests/threads.test.ts:397
- Unused variable result.
const result = await threadsService.createThread(inputThread as Thread)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -29,8 +31,7 @@ export class DefaultThreadsService implements ThreadsService { | |||
| : undefined | |||
|
|
|||
| // Check if this is a "real" assistant (has instructions) or just model storage | |||
There was a problem hiding this comment.
The comment says we only keep a "real" assistant when it has instructions, but the code now always forwards e.assistants unchanged. Please update/remove the comment to reflect the new behavior (or reintroduce the instructions-based filtering if that's still required).
| // Check if this is a "real" assistant (has instructions) or just model storage | |
| // Forward assistants array as-is (no filtering by instructions) |
| // Build assistants payload - always include model info | ||
| // If there's a real assistant (with instructions), include full assistant data | ||
| // Otherwise, just include minimal model-only entry for storage | ||
| const hasRealAssistant = thread.assistants && thread.assistants.length > 0 && thread.assistants[0]?.instructions | ||
| const hasRealAssistant = thread.assistants && thread.assistants.length > 0 | ||
| const assistantsPayload = hasRealAssistant |
There was a problem hiding this comment.
hasRealAssistant is now based only on thread.assistants.length > 0, but the nearby comments still describe "real assistant (with instructions)" behavior. Consider renaming the flag (or updating the comments) so the naming/docs match the actual condition being checked.
* fix: temporary disable prompt cache * fix: broken assistant selection * fix: default asistant * Merge pull request #7509 from janhq/fix/assistant-for-project fix: assistant for project does not work --------- Co-authored-by: Faisal Amir <urmauur@gmail.com>
Describe Your Changes
Fixes Issues
Self Checklist