<think> block delimiters are not detected correctly

Open Beginner friendly
#1,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
kotlin
Domain
ai

Research direction

Start with src/main/kotlin/ee/carlrobert/codegpt/util/ThinkingOutputParser.kt and src/main/kotlin/ee/carlrobert/codegpt/toolwindow/chat/parser/CompleteMessageParser.kt, where the newline requirement is enforced. Run the existing parser tests, then adjust the delimiter handling so a <think> block can end with `` followed by a single newline. Done means reasoning and answer content are parsed correctly regardless of one or two trailing newlines.

Written by the indexing model from the issue text.

Description

bug
What happened?

I am running Codestral locally (LM Studio -> Custom OpenAI config.)
There is an issue with ProxyAI not properly detecting the end of a <think>-block.

Inspecting the model's output, it properly does <think>{reasoning}</think>{answer}.

A little scouring through the code revealed the culprit:
The parsing expects (at least) 2 newlines after a </think>-tag. The model outputs a single newline after the think block. I have tried to instruct the model to output 2 newlines, but it sometimes will and sometimes won't, which makes this flaky.

I don´t know the reasoning (by the developer) behind this specific, but I think it should not assert 2 newlines, just look for <think>, and then </think>.
Neither the commit message, nor the issue linked to that commit state anything about this formatting.

The places that I found:
ThinkingOutputParser.kt#L7
CompleteMessageParser.kt#L17

Relevant log output or stack trace

Steps to reproduce
  • Run Codestral 22B v0.1 in LM Studio.
  • Register LM Studio as a Custom OpenAi-Like config
  • Use the Default Persona.
  • Try to generate something that requires reasoning.
CodeGPT version

3.4.3-241.1

Operating System

Linux

Dominant language
Kotlin
Stars
1.9k
Forks
401
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from carlrobertoh/ProxyAI

All issues in carlrobertoh/ProxyAI

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.