Skip to content

Commit af116dd

Browse files
authored
fix: jan should have a general assistant instruction (#5872)
* fix: default Jan assistant prompt * test: update tests
1 parent 3afdd0f commit af116dd

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

extensions/assistant-extension/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export default class JanAssistantExtension extends AssistantExtension {
7575
'Jan is a helpful desktop assistant that can reason through complex tasks and use tools to complete them on the user’s behalf.',
7676
model: '*',
7777
instructions:
78-
'You have access to a set of tools to help you answer the user’s question. You can use only one tool per message, and you’ll receive the result of that tool in the user’s next response. To complete a task, use tools step by step—each step should be guided by the outcome of the previous one.\nTool Usage Rules:\n1. Always provide the correct values as arguments when using tools. Do not pass variable names—use actual values instead.\n2. You may perform multiple tool steps to complete a task.\n3. Avoid repeating a tool call with exactly the same parameters to prevent infinite loops.',
78+
'You are a helpful AI assistant. Your primary goal is to assist users with their questions and tasks to the best of your abilities.\n\nWhen responding:\n- Answer directly from your knowledge when you can\n- Be concise, clear, and helpful\n- Admit when you’re unsure rather than making things up\n\nIf tools are available to you:\n- Only use tools when they add real value to your response\n- Use tools when the user explicitly asks (e.g., "search for...", "calculate...", "run this code")\n- Use tools for information you don’t know or that needs verification\n- Never use tools just because they’re available\n\nWhen using tools:\n- Use one tool at a time and wait for results\n- Use actual values as arguments, not variable names\n- Learn from each result before deciding next steps\n- Avoid repeating the same tool call with identical parameters\n\nRemember: Most questions can be answered without tools. Think first whether you need them.',
7979
tools: [
8080
{
8181
type: 'retrieval',

web-app/src/hooks/__tests__/useAssistant.test.ts

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,99 +22,99 @@ describe('useAssistant', () => {
2222

2323
it('should initialize with default state', () => {
2424
const { result } = renderHook(() => useAssistant())
25-
25+
2626
expect(result.current.assistants).toEqual([defaultAssistant])
2727
expect(result.current.currentAssistant).toEqual(defaultAssistant)
2828
})
2929

3030
it('should add assistant', () => {
3131
const { result } = renderHook(() => useAssistant())
32-
32+
3333
const newAssistant = {
3434
id: 'assistant-2',
3535
name: 'New Assistant',
3636
avatar: '🤖',
3737
description: 'A new assistant',
3838
instructions: 'Help the user',
3939
created_at: Date.now(),
40-
parameters: {}
40+
parameters: {},
4141
}
42-
42+
4343
act(() => {
4444
result.current.addAssistant(newAssistant)
4545
})
46-
46+
4747
expect(result.current.assistants).toHaveLength(2)
4848
expect(result.current.assistants).toContain(newAssistant)
4949
})
5050

5151
it('should update assistant', () => {
5252
const { result } = renderHook(() => useAssistant())
53-
53+
5454
const updatedAssistant = {
5555
...defaultAssistant,
5656
name: 'Updated Jan',
57-
description: 'Updated description'
57+
description: 'Updated description',
5858
}
59-
59+
6060
act(() => {
6161
result.current.updateAssistant(updatedAssistant)
6262
})
63-
63+
6464
expect(result.current.assistants[0].name).toBe('Updated Jan')
6565
expect(result.current.assistants[0].description).toBe('Updated description')
6666
})
6767

6868
it('should delete assistant', () => {
6969
const { result } = renderHook(() => useAssistant())
70-
70+
7171
const assistant2 = {
7272
id: 'assistant-2',
7373
name: 'Assistant 2',
7474
avatar: '🤖',
7575
description: 'Second assistant',
7676
instructions: 'Help the user',
7777
created_at: Date.now(),
78-
parameters: {}
78+
parameters: {},
7979
}
80-
80+
8181
act(() => {
8282
result.current.addAssistant(assistant2)
8383
})
84-
84+
8585
expect(result.current.assistants).toHaveLength(2)
86-
86+
8787
act(() => {
8888
result.current.deleteAssistant('assistant-2')
8989
})
90-
90+
9191
expect(result.current.assistants).toHaveLength(1)
9292
expect(result.current.assistants[0].id).toBe('jan')
9393
})
9494

9595
it('should set current assistant', () => {
9696
const { result } = renderHook(() => useAssistant())
97-
97+
9898
const newAssistant = {
9999
id: 'assistant-2',
100100
name: 'New Current Assistant',
101101
avatar: '🤖',
102102
description: 'New current assistant',
103103
instructions: 'Help the user',
104104
created_at: Date.now(),
105-
parameters: {}
105+
parameters: {},
106106
}
107-
107+
108108
act(() => {
109109
result.current.setCurrentAssistant(newAssistant)
110110
})
111-
111+
112112
expect(result.current.currentAssistant).toEqual(newAssistant)
113113
})
114114

115115
it('should set assistants', () => {
116116
const { result } = renderHook(() => useAssistant())
117-
117+
118118
const assistants = [
119119
{
120120
id: 'assistant-1',
@@ -123,7 +123,7 @@ describe('useAssistant', () => {
123123
description: 'First assistant',
124124
instructions: 'Help the user',
125125
created_at: Date.now(),
126-
parameters: {}
126+
parameters: {},
127127
},
128128
{
129129
id: 'assistant-2',
@@ -132,52 +132,56 @@ describe('useAssistant', () => {
132132
description: 'Second assistant',
133133
instructions: 'Help with tasks',
134134
created_at: Date.now(),
135-
parameters: {}
136-
}
135+
parameters: {},
136+
},
137137
]
138-
138+
139139
act(() => {
140140
result.current.setAssistants(assistants)
141141
})
142-
142+
143143
expect(result.current.assistants).toEqual(assistants)
144144
expect(result.current.assistants).toHaveLength(2)
145145
})
146146

147147
it('should maintain assistant structure', () => {
148148
const { result } = renderHook(() => useAssistant())
149-
149+
150150
expect(result.current.currentAssistant.id).toBe('jan')
151151
expect(result.current.currentAssistant.name).toBe('Jan')
152152
expect(result.current.currentAssistant.avatar).toBe('👋')
153-
expect(result.current.currentAssistant.description).toContain('helpful desktop assistant')
154-
expect(result.current.currentAssistant.instructions).toContain('access to a set of tools')
153+
expect(result.current.currentAssistant.description).toContain(
154+
'helpful desktop assistant'
155+
)
156+
expect(result.current.currentAssistant.instructions).toContain(
157+
'Only use tools when they add real value to your response'
158+
)
155159
expect(typeof result.current.currentAssistant.created_at).toBe('number')
156160
expect(typeof result.current.currentAssistant.parameters).toBe('object')
157161
})
158162

159163
it('should handle empty assistants list', () => {
160164
const { result } = renderHook(() => useAssistant())
161-
165+
162166
act(() => {
163167
result.current.setAssistants([])
164168
})
165-
169+
166170
expect(result.current.assistants).toEqual([])
167171
})
168172

169173
it('should update assistant in current assistant if it matches', () => {
170174
const { result } = renderHook(() => useAssistant())
171-
175+
172176
const updatedDefaultAssistant = {
173177
...defaultAssistant,
174-
name: 'Updated Jan Name'
178+
name: 'Updated Jan Name',
175179
}
176-
180+
177181
act(() => {
178182
result.current.updateAssistant(updatedDefaultAssistant)
179183
})
180-
184+
181185
expect(result.current.currentAssistant.name).toBe('Updated Jan Name')
182186
})
183-
})
187+
})

web-app/src/hooks/useAssistant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const defaultAssistant: Assistant = {
2121
description:
2222
'Jan is a helpful desktop assistant that can reason through complex tasks and use tools to complete them on the user’s behalf.',
2323
instructions:
24-
'You have access to a set of tools to help you answer the user’s question. You can use only one tool per message, and you’ll receive the result of that tool in the user’s next response. To complete a task, use tools step by step—each step should be guided by the outcome of the previous one.\nTool Usage Rules:\n1. Always provide the correct values as arguments when using tools. Do not pass variable names—use actual values instead.\n2. You may perform multiple tool steps to complete a task.\n3. Avoid repeating a tool call with exactly the same parameters to prevent infinite loops.',
24+
'You are a helpful AI assistant. Your primary goal is to assist users with their questions and tasks to the best of your abilities.\n\nWhen responding:\n- Answer directly from your knowledge when you can\n- Be concise, clear, and helpful\n- Admit when you’re unsure rather than making things up\n\nIf tools are available to you:\n- Only use tools when they add real value to your response\n- Use tools when the user explicitly asks (e.g., "search for...", "calculate...", "run this code")\n- Use tools for information you don’t know or that needs verification\n- Never use tools just because they’re available\n\nWhen using tools:\n- Use one tool at a time and wait for results\n- Use actual values as arguments, not variable names\n- Learn from each result before deciding next steps\n- Avoid repeating the same tool call with identical parameters\n\nRemember: Most questions can be answered without tools. Think first whether you need them.',
2525
}
2626

2727
export const useAssistant = create<AssistantState>()((set, get) => ({

0 commit comments

Comments
 (0)