Skip to content

Commit 618d107

Browse files
committed
chore: change reasoning tag from thinking to think
1 parent d4fc5af commit 618d107

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/core/task/Task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
23392339
let finalAssistantMessage = assistantMessage
23402340
if (reasoningMessage && this.api.getModel().info.preserveReasoning) {
23412341
// Prepend reasoning in XML tags to the assistant message so it's included in API history
2342-
finalAssistantMessage = `<thinking>${reasoningMessage}</thinking>\n${assistantMessage}`
2342+
finalAssistantMessage = `<think>${reasoningMessage}</think>\n${assistantMessage}`
23432343
}
23442344

23452345
await this.addToApiConversationHistory({

src/core/task/__tests__/reasoning-preservation.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,29 +142,29 @@ describe("Task reasoning preservation", () => {
142142
// Simulate what happens in the streaming loop when preserveReasoning is true
143143
let finalAssistantMessage = assistantMessage
144144
if (reasoningMessage && task.api.getModel().info.preserveReasoning) {
145-
finalAssistantMessage = `<thinking>${reasoningMessage}</thinking>\n${assistantMessage}`
145+
finalAssistantMessage = `<think>${reasoningMessage}</think>\n${assistantMessage}`
146146
}
147147

148148
await (task as any).addToApiConversationHistory({
149149
role: "assistant",
150150
content: [{ type: "text", text: finalAssistantMessage }],
151151
})
152152

153-
// Verify that reasoning was prepended in <thinking> tags to the assistant message
153+
// Verify that reasoning was prepended in <think> tags to the assistant message
154154
expect(addToApiHistorySpy).toHaveBeenCalledWith({
155155
role: "assistant",
156156
content: [
157157
{
158158
type: "text",
159-
text: "<thinking>Let me think about this step by step. First, I need to...</thinking>\nHere is my response to your question.",
159+
text: "<think>Let me think about this step by step. First, I need to...</think>\nHere is my response to your question.",
160160
},
161161
],
162162
})
163163

164164
// Verify the API conversation history contains the message with reasoning
165165
expect(task.apiConversationHistory).toHaveLength(1)
166-
expect(task.apiConversationHistory[0].content[0].text).toContain("<thinking>")
167-
expect(task.apiConversationHistory[0].content[0].text).toContain("</thinking>")
166+
expect(task.apiConversationHistory[0].content[0].text).toContain("<think>")
167+
expect(task.apiConversationHistory[0].content[0].text).toContain("</think>")
168168
expect(task.apiConversationHistory[0].content[0].text).toContain("Here is my response to your question.")
169169
expect(task.apiConversationHistory[0].content[0].text).toContain(
170170
"Let me think about this step by step. First, I need to...",
@@ -207,7 +207,7 @@ describe("Task reasoning preservation", () => {
207207
// Simulate what happens in the streaming loop when preserveReasoning is false
208208
let finalAssistantMessage = assistantMessage
209209
if (reasoningMessage && task.api.getModel().info.preserveReasoning) {
210-
finalAssistantMessage = `<thinking>${reasoningMessage}</thinking>\n${assistantMessage}`
210+
finalAssistantMessage = `<think>${reasoningMessage}</think>\n${assistantMessage}`
211211
}
212212

213213
await (task as any).addToApiConversationHistory({
@@ -224,7 +224,7 @@ describe("Task reasoning preservation", () => {
224224
// Verify the API conversation history does NOT contain reasoning
225225
expect(task.apiConversationHistory).toHaveLength(1)
226226
expect(task.apiConversationHistory[0].content[0].text).toBe("Here is my response to your question.")
227-
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<thinking>")
227+
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<think>")
228228
})
229229

230230
it("should handle empty reasoning message gracefully when preserveReasoning is true", async () => {
@@ -262,7 +262,7 @@ describe("Task reasoning preservation", () => {
262262
// Simulate what happens in the streaming loop
263263
let finalAssistantMessage = assistantMessage
264264
if (reasoningMessage && task.api.getModel().info.preserveReasoning) {
265-
finalAssistantMessage = `<thinking>${reasoningMessage}</thinking>\n${assistantMessage}`
265+
finalAssistantMessage = `<think>${reasoningMessage}</think>\n${assistantMessage}`
266266
}
267267

268268
await (task as any).addToApiConversationHistory({
@@ -278,7 +278,7 @@ describe("Task reasoning preservation", () => {
278278

279279
// Verify the message doesn't contain reasoning tags
280280
expect(task.apiConversationHistory[0].content[0].text).toBe("Here is my response.")
281-
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<thinking>")
281+
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<think>")
282282
})
283283

284284
it("should handle undefined preserveReasoning (defaults to false)", async () => {
@@ -313,7 +313,7 @@ describe("Task reasoning preservation", () => {
313313
// Simulate what happens in the streaming loop
314314
let finalAssistantMessage = assistantMessage
315315
if (reasoningMessage && task.api.getModel().info.preserveReasoning) {
316-
finalAssistantMessage = `<thinking>${reasoningMessage}</thinking>\n${assistantMessage}`
316+
finalAssistantMessage = `<think>${reasoningMessage}</think>\n${assistantMessage}`
317317
}
318318

319319
await (task as any).addToApiConversationHistory({
@@ -323,6 +323,6 @@ describe("Task reasoning preservation", () => {
323323

324324
// Verify reasoning was NOT prepended (undefined defaults to false)
325325
expect(task.apiConversationHistory[0].content[0].text).toBe("Here is my response.")
326-
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<thinking>")
326+
expect(task.apiConversationHistory[0].content[0].text).not.toContain("<think>")
327327
})
328328
})

0 commit comments

Comments
 (0)