Skip to content
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

Fix Apply failure with <think> tags (#283) #287

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jhacksman
Copy link

@jhacksman jhacksman commented Feb 15, 2025

  • Add utility to strip tags from responses
  • Strip tags before computing diffs in Apply operation
  • Handle nested tags properly
  • Keep original response intact for UI display

Fixes #283


Important

Add stripThinkTags() to remove <think> tags from chat responses, ensuring diffs are computed correctly while keeping original responses intact for UI.

  • Behavior:
    • Add stripThinkTags() in chatModel.ts to remove <think> tags from text, handling nested tags.
    • Use stripThinkTags() in getChatConversation() in codeBlockOperations.ts to strip tags before computing diffs.
    • Original response remains unchanged for UI display.
  • Functions:
    • stripThinkTags() added to handle nested <think> tags.
    • getChatConversation() updated to use stripThinkTags() for response processing.

This description was created by Ellipsis for 7849b0a. It will automatically update as commits are pushed.

- Add utility to strip <think> tags from responses
- Strip tags before computing diffs in Apply operation
- Handle nested tags properly
- Keep original response intact for UI display

Fixes voideditor#283

Co-Authored-By: Jack Hacksman <[email protected]>
Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 7849b0a in 2 minutes and 43 seconds

More details
  • Looked at 69 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.ts:389
  • Draft comment:
    Ensure that stripping tags here strictly affects the diff computation and does not alter the UI display. The transformation looks correct, but verify that any legitimate appearing after the initial block is preserved if intended.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    The comment is asking the author to ensure that a specific change does not affect the UI display, which is against the rules. It also asks to verify the preservation of certain tags, which is similar to asking for confirmation of intention. This comment should be removed.
2. src/vs/workbench/contrib/chat/common/chatModel.ts:358
  • Draft comment:
    The stripThinkTags function removes all blocks in the text. According to requirements, only the initial block (if present at the very beginning) should be stripped. Consider adding a check to only remove the first block and leave subsequent tags intact if they are part of the intended answer.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
    The comment makes a claim about requirements, but I don't see any evidence in the code or comments that suggests this requirement exists. The function's documentation clearly states it removes ALL think tags. The stack-based approach seems intentional for handling nested tags. Without seeing clear evidence of the "initial block only" requirement, I should be skeptical of this comment.
    I could be wrong if there are requirements documented elsewhere that specify only the first block should be removed. The commenter may have access to information I don't have.
    However, the function's own documentation and implementation clearly indicate the intended behavior is to remove all tags. If there was such a requirement, it would likely be mentioned in the function's documentation.
    The comment should be deleted because it makes claims about requirements without evidence, and contradicts the clear intent shown in the function's documentation and implementation.
3. src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.ts:389
  • Draft comment:
    Good change: stripping tags before diff computation resolves the diff desync without altering the displayed response.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. src/vs/workbench/contrib/chat/common/chatModel.ts:369
  • Draft comment:
    Consider adding a safeguard in stripThinkTags for unmatched closing tags (when depth goes negative) to ensure extra '' tags don't suppress subsequent text.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_70uHRjke5fjYhxZB


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@andrewpareles
Copy link
Contributor

andrewpareles commented Feb 15, 2025

Nice work. Can deepseek really do nested thinking? How does their chat interface deal with this?

Would be ideal to add support for streaming, so if it types <thi the user doesn't see it. We have code for this in extractCodeFromResult.ts, I can add this if it's a pain for you.

Also preferably we would only apply this to models that actually produce tags when thinking, will revisit this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI code block “Apply” fails due to <think> tags at start of response (diff desync) (deepseek-r1-671b)
2 participants