Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1941,10 +1941,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
}

switch (chunk.type) {
case "reasoning":
case "reasoning": {
reasoningMessage += chunk.text
await this.say("reasoning", reasoningMessage, undefined, true)
// Only apply formatting if the message contains sentence-ending punctuation followed by **
let formattedReasoning = reasoningMessage
if (reasoningMessage.includes("**")) {
// Add line breaks before **Title** patterns that appear after sentence endings
// This targets section headers like "...end of sentence.**Title Here**"
// Handles periods, exclamation marks, and question marks
formattedReasoning = reasoningMessage.replace(
/([.!?])\*\*([^*\n]+)\*\*/g,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix for reasoning block formatting – the regex /([.!?])\*\*([^*\n]+)\*\*/g inserts double newlines before bold headers following sentence-ending punctuation, which should improve readability. Consider extracting this formatting logic into a helper (e.g. formatReasoningMessage) for better testability and reuse. Also, the preliminary check if (reasoningMessage.includes("**")) may be redundant since the regex replace safely does nothing if no match is found.

This comment was generated because it violated a code review rule: irule_tTqpIuNs8DV0QFGj.

"$1\n\n**$2**",
)
}
await this.say("reasoning", formattedReasoning, undefined, true)
break
}
case "usage":
inputTokens += chunk.inputTokens
outputTokens += chunk.outputTokens
Expand Down
Loading