-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Fix: Improve reasoning block formatting for better readability #7868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice fix for reasoning block formatting – the regex This comment was generated because it violated a code review rule: irule_tTqpIuNs8DV0QFGj. |
||
| "$1\n\n**$2**", | ||
| ) | ||
| } | ||
| await this.say("reasoning", formattedReasoning, undefined, true) | ||
daniel-lxs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| break | ||
| } | ||
| case "usage": | ||
| inputTokens += chunk.inputTokens | ||
| outputTokens += chunk.outputTokens | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.